Utils module - fastf1.utils

fastf1.utils.delta_time(reference_lap, compare_lap)[source]

Calculates the delta time of a given lap, along the ‘Distance’ axis of the reference lap.


This is a nice gimmick but not actually very accurate which is an inherent problem from the way this is calculated currently (There may not be a better way though). In comparison with the sector times and the differences that can be calculated from these, there are notable differences! You should always verify the result against sector time differences or find a different way for verification.

Here is an example that compares the quickest laps of Leclerc and Hamilton from Bahrain 2021 Qualifying:

import fastf1 as ff1
from fastf1 import plotting
from fastf1 import utils
from matplotlib import pyplot as plt


session = ff1.get_session(2021, 'Emilia Romagna', 'Q')
lec = session.laps.pick_driver('LEC').pick_fastest()
ham = session.laps.pick_driver('HAM').pick_fastest()

delta_time, ref_tel, compare_tel = utils.delta_time(ham, lec)
# ham is reference, lec is compared

fig, ax = plt.subplots()
# use telemetry returned by .delta_time for best accuracy,
# this ensure the same applied interpolation and resampling
ax.plot(ref_tel['Distance'], ref_tel['Speed'],
ax.plot(compare_tel['Distance'], compare_tel['Speed'],

twin = ax.twinx()
twin.plot(ref_tel['Distance'], delta_time, '--', color='white')
twin.set_ylabel("<-- Lec ahead | Ham ahead -->")

(png, hires.png, pdf)

  • reference_lap (pd.Series) – The lap taken as reference

  • compare_lap (pd.Series) – The lap to compare


(delta, reference, comparison)
  • pd.Series of type float64 with the delta in seconds.

  • Telemetry for the reference lap

  • Telemetry for the comparison lap

Use the return telemetry for plotting to make sure you have telemetry data that was created with the same interpolation and resampling options!

Return type


fastf1.utils.recursive_dict_get(d, *keys, default_none=False)[source]

Recursive dict get. Can take an arbitrary number of keys and returns an empty dict if any key does not exist. https://stackoverflow.com/a/28225747


Fast timedelta object creation from a time string

Permissible string formats:

For example: 13:24:46.320215 with:

  • optional hours and minutes

  • optional microseconds and milliseconds with arbitrary precision (1 to 6 digits)

Examples of valid formats:

  • 24.3564 (seconds + milli/microseconds)

  • 36:54 (minutes + seconds)

  • 8:45:46 (hours, minutes, seconds)


x (str or timedelta) –




Fast datetime object creation from a date string.

Permissible string formats:

For example ‘2020-12-13T13:27:15.320000Z’ with:

  • optional milliseconds and microseconds with arbitrary precision (1 to 6 digits)

  • with optional trailing letter ‘Z’

Examples of valid formats:

  • 2020-12-13T13:27:15.320000

  • 2020-12-13T13:27:15.32Z

  • 2020-12-13T13:27:15


x (str or datetime) –