Public
Edited
Mar 8, 2023
Insert cell
Insert cell
haas_summary.view()
Insert cell
haas_summary = aq.from(query)
.groupby("surname")
.rollup({
avg_points: d => op.mean(d.points),
crash_retirements: d => op.sum(op.includes(["Accident", "Collision", "Collision damage"], d.status)),
points_finishes: d => op.sum(d.points > 0),
total_races: d => op.count()
})
.derive({
crashRetirementPercent: d => d.crash_retirements / d.total_races,
pointsFinishPercent: d => d.points_finishes / d.total_races
})
.filter(d => d.total_races > 20) // get rid of pietro Fitipaldi
.orderby(aq.desc('crashRetirementPercent'))
Insert cell
Plot.plot({
x:{
tickFormat: "p"
},
y:{
tickFormat: "p"
},
marks:[
Plot.text(haas_summary, {x: "crashRetirementPercent", y: "pointsFinishPercent", text: "surname"}),
Plot.ruleX([0]),
Plot.ruleY([0])
]
})
Insert cell
pointsFinishCountsYear = aq.from(query)
.filter(d => !op.includes(
["Fittipaldi", "Gutiérrez", "Mazepin"], d.surname)
) // already know these guys never scored
.groupby("year", "surname")
.rollup({
points_finishes: d => op.sum(d.points > 0),
points_scored: d => op.sum(d.points)
})
Insert cell
viewof pointsVar = Inputs.radio(new Map([["# of points finishes", "points_finishes"],
["Total points scored", "points_scored"]]),
{label: "Plot variable:", value: "points_finishes"})
Insert cell
Plot.plot({
x:{
tickFormat: "d"
},
color: {
legend: true
},
marks: [
Plot.barY(pointsFinishCountsYear, {x: "year", y: pointsVar, fill: "surname"})
]
})
Insert cell
database = FileAttachment("f1_db.sqlite").sqlite()
Insert cell
database
SELECT res.grid, drivers.driverRef, drivers.surname, res.laps, res.position, res.points, ra.year, ra.name, st.status
FROM results AS res
LEFT JOIN races AS ra
on res.raceId=ra.raceID
LEFT JOIN drivers
on res.driverId=drivers.driverId
LEFT JOIN status AS st
on res.statusId=st.statusId
LEFT JOIN constructors AS co
on res.constructorId=co.constructorId
WHERE st.status NOT IN ("Did not qualify", "Did not prequalify") AND
co.constructorRef = 'haas';
Insert cell
import {op, aq} from "@uwdata/arquero"
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more