Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/TracingInsights/tif1/llms.txt

Use this file to discover all available pages before exploring further.

Overview

The Driver class represents a driver in a session as a pandas Series. It provides access to driver-specific information, laps, and convenience methods for retrieving fastest laps and telemetry.

Constructor

Driver(session, driver, prefetched_lap_data=None)
session
Session
required
Parent Session object
driver
str
required
Driver code (e.g., “VER”, “HAM”)
prefetched_lap_data
dict
default:"None"
Optional prefetched lap data for optimization

Attributes

The Driver object is a pandas Series containing driver information:
  • DriverNumber (str): Driver racing number
  • Abbreviation (str): Driver code (e.g., “VER”)
  • TeamName (str): Team name
  • TeamColor (str): Team color hex code
  • FirstName (str): Driver first name
  • LastName (str): Driver last name
  • FullName (str): Full name (first + last)
  • HeadshotUrl (str): URL to driver headshot image

session

driver.session -> Session
Reference to the parent Session object.

driver

driver.driver -> str
Driver code (e.g., “VER”, “HAM”).

Properties

laps

driver.laps -> DataFrame
Get laps for this driver. Returns a DataFrame with all lap timing data for the driver. Returns: DataFrame with columns:
  • LapNumber, LapTime, Driver, Team
  • Sector1Time, Sector2Time, Sector3Time
  • Compound, TyreLife, Stint
  • Position, TrackStatus, IsPersonalBest
  • And more…
Returns empty DataFrame if no data found.

Methods

get_lap

driver.get_lap(lap_number) -> Lap
Get specific lap by lap number.
lap_number
int
required
Lap number to retrieve
Returns: Lap object containing lap timing data and telemetry access Raises:
  • LapNotFoundError: If the lap number doesn’t exist for this driver
Example:
driver = session.get_driver("VER")
lap = driver.get_lap(15)
print(f"Lap time: {lap['LapTime']}")
print(f"Sector 1: {lap['Sector1Time']}")

get_fastest_lap

driver.get_fastest_lap() -> DataFrame
Get driver’s fastest lap. Returns: Single-row DataFrame with the fastest lap data. Returns empty DataFrame if no valid laps found. Example:
driver = session.get_driver("VER")
fastest = driver.get_fastest_lap()
if not fastest.empty:
    print(f"Fastest lap: {fastest.iloc[0]['LapTime']}")
    print(f"On lap: {fastest.iloc[0]['LapNumber']}")
    print(f"Compound: {fastest.iloc[0]['Compound']}")

get_fastest_lap_tel

driver.get_fastest_lap_tel() -> DataFrame
Get telemetry from driver’s fastest lap. Returns: DataFrame with telemetry data from the fastest lap:
  • Time: Time offset from lap start
  • SessionTime: Time offset from session start
  • Speed: Speed in km/h
  • RPM: Engine RPM
  • nGear: Gear number
  • Throttle: Throttle position (0-100)
  • Brake: Brake status (boolean or 0-100)
  • DRS: DRS status
  • X, Y, Z: Position coordinates
  • Distance: Distance along track
Returns empty DataFrame if telemetry not found. Example:
driver = session.get_driver("HAM")
telemetry = driver.get_fastest_lap_tel()
if not telemetry.empty:
    max_speed = telemetry['Speed'].max()
    print(f"Max speed on fastest lap: {max_speed} km/h")

Usage Examples

Basic Driver Info

import tif1

session = tif1.get_session(2025, "Monaco Grand Prix", "Race")
driver = session.get_driver("VER")

# Access driver information
print(f"Name: {driver['FullName']}")
print(f"Number: {driver['DriverNumber']}")
print(f"Team: {driver['TeamName']}")
print(f"Team Color: {driver['TeamColor']}")

Working with Laps

driver = session.get_driver("VER")
laps = driver.laps

# Basic statistics
print(f"Total laps: {len(laps)}")
print(f"Average lap time: {laps['LapTime'].mean()}")
print(f"Best lap time: {laps['LapTime'].min()}")

# Filter by compound
soft_laps = laps[laps['Compound'] == 'SOFT']
print(f"Laps on SOFT tyres: {len(soft_laps)}")

Analyzing Fastest Lap

driver = session.get_driver("HAM")
fastest = driver.get_fastest_lap()

if not fastest.empty:
    lap_data = fastest.iloc[0]
    print(f"Fastest lap: {lap_data['LapNumber']}")
    print(f"Time: {lap_data['LapTime']}")
    print(f"Sector 1: {lap_data['Sector1Time']}")
    print(f"Sector 2: {lap_data['Sector2Time']}")
    print(f"Sector 3: {lap_data['Sector3Time']}")
    print(f"Compound: {lap_data['Compound']}")
    print(f"Tyre life: {lap_data['TyreLife']} laps")

Telemetry Analysis

driver = session.get_driver("LEC")
tel = driver.get_fastest_lap_tel()

if not tel.empty:
    # Speed analysis
    max_speed = tel['Speed'].max()
    avg_speed = tel['Speed'].mean()
    print(f"Max speed: {max_speed:.1f} km/h")
    print(f"Average speed: {avg_speed:.1f} km/h")
    
    # Gear usage
    gear_counts = tel['nGear'].value_counts().sort_index()
    print("Gear usage:")
    for gear, count in gear_counts.items():
        print(f"  Gear {gear}: {count} samples")
    
    # Throttle application
    full_throttle_pct = (tel['Throttle'] >= 99).sum() / len(tel) * 100
    print(f"Full throttle: {full_throttle_pct:.1f}% of lap")

Getting Specific Lap

driver = session.get_driver("VER")

try:
    lap = driver.get_lap(15)
    print(f"Lap 15 time: {lap['LapTime']}")
    print(f"Position: {lap['Position']}")
    print(f"Compound: {lap['Compound']}")
    
    # Get telemetry for this lap
    tel = lap.telemetry
    print(f"Telemetry samples: {len(tel)}")
except LapNotFoundError:
    print("Lap 15 not found for this driver")

Comparing Multiple Drivers

session = tif1.get_session(2025, "Monaco Grand Prix", "Qualifying")

drivers_to_compare = ["VER", "HAM", "LEC"]

for driver_code in drivers_to_compare:
    driver = session.get_driver(driver_code)
    fastest = driver.get_fastest_lap()
    
    if not fastest.empty:
        lap_time = fastest.iloc[0]['LapTime']
        print(f"{driver['FullName']}: {lap_time}")

Stint Analysis

driver = session.get_driver("VER")
laps = driver.laps

# Group by stint
for stint_num in laps['Stint'].unique():
    stint_laps = laps[laps['Stint'] == stint_num]
    compound = stint_laps.iloc[0]['Compound']
    lap_count = len(stint_laps)
    avg_time = stint_laps['LapTime'].mean()
    
    print(f"Stint {stint_num}: {compound} ({lap_count} laps, avg {avg_time:.3f}s)")

See Also

  • Session - Main session object
  • Lap - Single lap data
  • Laps - Collection of laps
  • Telemetry - Telemetry data operations

Build docs developers (and LLMs) love