Formula 1 Tyre Analytics with Python

Dimitris Chortarias
3 min readMar 14, 2022

Formula 1 Tyre analysis for 2021 Formula 1 Season using Python, Streamlit, pandas, numpy

https://share.streamlit.io/dimitrisnismo/formula1_tyreanalytics/main/main.py

Abu Dhabi Tyre Analytics

I Love Formula 1. I love racing and also I love data. This article is about tyre analysis for Formula 1 2021 Season how to implement,visualize and analyze the results with python.

Data:

The data have been retrieved with the fastf1 python package. Below is a snap of code for loading the data

Load Lap Times

Cleaning and working with the data:

1.Remove Races where have been used WET or INTERMEDIATE Compound.

2. Adding the difference between two cars. In order to remove these rows.(we need clean lap

3. Filter Dataframe based on the conditions below:

a.No pit in or pit out time

b. Track status is ok (no Red Flag, Yellow Flags,VSC,SC)

c. Removing laptimes where the car in fron is less than 1.1 Seconds

4. Converting Lap Time in Seconds

5. Clean Lap Times based on Quartiles for each compound and for each race. (value≥Q1–1.5*IQR) & ( value≤Q3+1.5*IQR )

6. Remove Lap Times without Compound Type

7. Calculating the number number of the Compound. For example if there are two sets of soft tyres in a race the first set of tyres is SOFT_1

Visualizing Data:

To visualize the data it has been used Streamlit . To access the report click here.

Snapshot of the Analysis

Results:

Laptimes are lower:

First of all, I couldn’t expect that lap times are lower lap by lap. That means, drivers after each lap are more comfortable with the car and with the specific tyres so the can gain more time each lap. Also do not forget that fuel is lower every lap.

Tsunoda looks like the best driver.He gains the most from the tires lap by lap, while he is one the 2021 rookies.

Leclerc is the only driver who is losing time. I can explain this one as overheating the tyres or getting the maximum performance from the tyres ach lap. (?)

The Azerbaijan Grand Prix is the one with the most gained time, while Bahrain Grand Prix is the worst (?) I am confident to say that the Grand Pri Races where the track is more difficult, drivers gaining time lap by lap.

Feel free to investigate, explore and get more insights using the link above.

You can find full code here. https://github.com/dimitrisnismo/Formula1_TyreAnalytics

--

--