Chapter 2 Instructor Notes — The F1 Data Pipeline

Chapter: The F1 Data Pipeline: OpenF1, Jolpica, FastF1, and Building Your Analysis Environment · Exercises · Quiz · Case Study 1 · Case Study 2 · Key Takeaways · Discussion guide

Chapter 2 is the course's data-literacy chapter. It explains where every number in the book comes from: OpenF1 for detail (2023 onward), Jolpica-F1 for depth (results since 1950), and why FastF1, although excellent, is not a dependency. Its real subject is judgment: what counts as a clean lap, how two sources are joined, and how to spot a broken telemetry feed before it spoils an analysis. Students build boxbox/data.py, the loader every later chapter uses.

There is no threshold concept in this chapter, but there is a habit to install: clean by reasons first, thresholds second, and always read the rows that didn't match.

Learning objectives

By the end of the session, students should be able to:

  1. Name the three layers of the pipeline (raw, processed, analysis) and explain why raw files are never edited.
  2. Choose the right source for a question: Jolpica for history and depth, OpenF1 for laps, stints, race control and telemetry.
  3. Apply the five clean-lap rules in order and read the resulting funnel.
  4. Explain why the 107 % reference is a driver's own stint median, not the session best.
  5. Join OpenF1 and Jolpica with an outer join on keys, and interpret the unmatched rows.
  6. Describe the limits of public telemetry: sample rate, integrated distance, frozen feeds and missing channels.
  7. Load a race with RaceData.load and run summary() and coverage() before any analysis.

Suggested 75-minute session plan

Time Segment What happens
0–8 min Hook Put one number on the screen: Pérez, 2023 Japanese GP, lap 14 = 2,588.523 s, flagged GREEN. Ask: "Is this a mistake?" Reveal: it is a real line-to-line measurement around a 2,485.9 s pit-lane stay. Timing data are literal.
8–22 min Concept The three layers and the two sources. The clean-lap funnel for 2023–2026 race laps: 101,949 → not lap 1 (−1,854) → not pit in/out (−6,627) → GREEN (−8,099) → timed (−0: the flag step already took every untimed lap) → ≤107 % of stint median (−488) = 84,881 (83.3 %).
22–40 min Live demo Run code/03_cleaning_funnel.py, then code/04_joins_across_sources.py. Show the lap-time agreement: 99.991 % exact from lap 2, 0 % on lap 1 (median offset +0.389 s). Then show the hole: the 2025 Miami GP has no OpenF1 laps 2–24.
40–60 min Activity Small groups get the "107 % two ways" result: the stint-median rule keeps 99.4 % of candidate laps, session-best × 1.07 keeps 89.8 %, and 64 % of the extra laps it drops come from cars finishing P11 or lower. Each group writes one sentence on which rule biases a pace study, and towards whom.
60–75 min Wrap-up Run code/05_telemetry_pipeline.py (about 30 s) and show a frozen trace. 9.4 % of drivers' fastest 2026 qualifying laps contain a frozen stretch longer than 2 s. Exit ticket: "Name one check you will run before trusting any lap."

Key numbers students should leave with

  • Snapshot: 470 sessions; 268,783 laps, of which 150,184 (55.9 %) are clean. Race laps 101,949; clean 84,881 (83.3 %).
  • Jolpica depth: results 26,335 rows from 1950; lap times from 1996; pit-lane times from 2011.
  • Source agreement: OpenF1 and Jolpica race lap times agree to the millisecond on 99.991 % of laps from lap 2; lap 1 never agrees (OpenF1 a median 0.389 s longer).
  • Stint-boundary fix: 396 of 3,163 race stint starts (12.5 %) moved from in-lap to out-lap, all at Monaco (89 %), Montreal (88 %) and Melbourne (78 %). It changes green-flag pit loss at those circuits by 2.4–5.4 s (e.g. Albert Park 20.91 s fixed vs 15.55 s raw).
  • Telemetry: median sample interval 0.240 s (mean 3.74 Hz), roughly 24 m between samples above 300 km/h. Integrated distance runs a median 0.94 % short of the official length.
  • Frozen feeds: 9.4 % of fastest 2026 qualifying laps freeze for more than 2 s; the 2026 Suzuka pole lap is frozen for its last 24.7 s.
  • Speed trap vs sampled top speed: the sampled maximum exceeds the trap by a median 13 km/h (range +3 to +44).

Common misconceptions and remedies

Misconception Remedy
"A lap time is a lap of racing." Show the Pérez lap: it includes 41 minutes in the pit lane. Clean by reasons (lap 1, pit laps, flags) before applying thresholds.
"The fastest lap in a session is the pole lap." Qualifying is classified by Q3. In wet 2026 Brazil qualifying, Russell's fastest lap came in Q2, but Norris took pole.
"Jolpica is just an old version of OpenF1." Each has things the other lacks: Jolpica's 77 seasons of results and pit-lane times; OpenF1's stints, compounds, race control and telemetry.
"Inner joins are safe." An inner join hides exactly the rows you need to see. Outer join with an indicator, then read the unmatched rows (that is how the Miami hole was found).
"brake = 100 is full brake pressure." It is on/off only. The public stream has no brake pressure, steering, g, tyre temperature or ERS channels.
"Deleted laps should always be removed." It depends on the question. For race pace the lap was still driven at race speed; for qualifying-style questions, exclude them.
"Telemetry distance is measured." It is integrated from speed and drifts. Comparing two laps on integrated distance can create fake time differences; Chapter 7 shows how.

Exercises to assign

  • Core (everyone): Part A — A1, A4, A7, A9; Part B — B2 (trapezoid integration), B5 (the cost of not cleaning), B6 (pit call arithmetic).
  • Setup lab (required before Chapter 3): Part C — C1 (set up and reproduce). Treat this as a pass/fail gate.
  • Code lab: Part C — C2 (2024 Japanese GP race) and C3 (Antonelli vs Verstappen, 2026 Monaco GP qualifying).
  • Judgment: Part D — D1 (Montreal with a stale notebook) and D4 (is a deleted lap "clean"?).
  • Stretch: Part C — C6 (frozen telemetry by circuit); Part E — E1 (a data-quality dashboard) or E3 (reconstruct a race without OpenF1 laps).
  • Interleaving: Part M — M2 (g-forces from a frozen lap) ties the frozen-feed problem back to Chapter 1.

Lab tips

  • No network calls. All scripts read the book's data snapshot from disk, so they behave the same in a lab with poor Wi-Fi. Make sure the snapshot is installed before the session.
  • Run order: scripts 01_data_snapshot.py to 06_stint_boundary_fix.py stand alone. case_study_02.py writes code/case_study_02_scorecard.csv. Only 05_telemetry_pipeline.py takes noticeable time (about 30 s).
  • Start the lab with C1. Students who cannot run the test suite at the start of the term will struggle in every later chapter. Pair them with a code-first student.
  • Gotcha — names vs keys: the 2026 round held in Kuala Lumpur appears as "Bahrain Grand Prix" in OpenF1 and "Bahrain Grand Prix in Malaysia" in Jolpica; R20 is "São Paulo Grand Prix" in one and "Brazilian Grand Prix" in the other. Join on session_key, driver_ref and dates.
  • Gotcha — car numbers changed for 2026: Verstappen 1 → 3, Norris 4 → 1. Match drivers by number and surname.
  • Gotcha — 2025 Miami: OpenF1 has no laps 2–24 and wrong stint boundaries for 15 of 18 drivers. Exclude it from stint or degradation work, or use Jolpica lap times.
  • Gotcha — zero track temperatures: 44 weather records read 0.0 °C. summary() treats them as missing; students' own code should too.

Connections

  • Backward: Chapter 1 used the telemetry this chapter explains; its quality gate (check_lap) makes more sense after section 2.8.
  • Forward: every chapter loads data with RaceData. The clean-lap rule feeds Chapter 4's degradation fits and Chapter 12's pit-loss numbers; the alignment caveat returns in Chapter 7 and Chapter 19.