
Loading the Data
This example uses the 2024 Abu Dhabi Grand Prix. It loads the session with thepolars lib and converts the laps to pandas for plotting.
Cleaning the Data
In a race, lap times can be skewed by:- Safety Car periods (very slow laps)
- Pit stops (very slow laps)
- Lap 1 (standing start)
LapTime is a Duration, and to_pandas() turns it into timedelta64[ns]. The code below uses the float LapTimeSeconds column, which compares and plots in seconds.
Comparing Drivers
Compare the race pace of two drivers.Interpreting the Results
- Median (line in the box): Represents the typical race pace.
- Box size (IQR): Represents consistency. A smaller box means the driver was more consistent.
- Whiskers/Outliers: Show variance caused by traffic or minor errors.
Visualizing Pace Over the Race
Plot lap times against lap numbers to see how the pace evolved (tire degradation).Conclusion
Follow this workflow to:- Load high-quality timing data.
- Clean it to remove anomalies.
- Compare drivers using statistical distributions.
- Visualize performance trends across the entire race.