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 Laps class is a pandas DataFrame subclass for accessing lap (timing) data of multiple laps. It provides convenient filtering and selection methods optimized for F1 lap analysis.

Properties

telemetry

laps.telemetry -> Telemetry
Get telemetry data for all laps. Only works for laps from a single driver. Returns: Telemetry DataFrame with telemetry data from all laps concatenated Raises:
  • ValueError: If laps contain multiple drivers

Methods

pick_driver

laps.pick_driver(identifier) -> Laps
Filter laps for a specific driver.
identifier
str | int | dict
required
Driver identifier: driver code (“VER”), driver number (1), or driver dict
Returns: Filtered Laps object Example:
laps = session.laps
ver_laps = laps.pick_driver("VER")
ver_laps = laps.pick_driver(1)  # By number

pick_drivers

laps.pick_drivers(identifiers) -> Laps
Filter laps for multiple drivers.
identifiers
list[str | int | dict]
required
List of driver identifiers
Returns: Filtered Laps object Example:
top3_laps = laps.pick_drivers(["VER", "HAM", "LEC"])

pick_lap

laps.pick_lap(lap_number) -> Laps
Filter laps for a specific lap number.
lap_number
int
required
Lap number to filter
Returns: Filtered Laps object Example:
lap_1 = laps.pick_lap(1)

pick_laps

laps.pick_laps(laps) -> Laps
Filter laps by lap number range or list.
laps
slice | int | list[int]
required
Lap number(s): slice (e.g., 1:10), single int, or list of ints
Returns: Filtered Laps object Example:
# First 10 laps
first_10 = laps.pick_laps(slice(1, 10))
# Or using Python slice syntax
first_10 = laps.pick_laps(1:10)

# Specific laps
selected = laps.pick_laps([5, 10, 15, 20])

# From lap 10 onwards
from_10 = laps.pick_laps(slice(10, None))

pick_team

laps.pick_team(name) -> Laps
Filter laps for a specific team.
name
str
required
Team name
Returns: Filtered Laps object

pick_teams

laps.pick_teams(names) -> Laps
Filter laps for multiple teams.
names
list[str]
required
List of team names
Returns: Filtered Laps object Example:
red_bull_laps = laps.pick_team("Red Bull Racing")
top_teams = laps.pick_teams(["Red Bull Racing", "Mercedes", "Ferrari"])

pick_fastest

laps.pick_fastest(only_by_time=False) -> Lap | None
Get the fastest lap.
only_by_time
bool
default:"False"
Reserved for future use
Returns: Single Lap object with the fastest lap, or None if no valid laps Example:
fastest = laps.pick_fastest()
if fastest is not None:
    print(f"Fastest: {fastest['Driver']} - {fastest['LapTime']}")

pick_quicklaps

laps.pick_quicklaps(threshold=1.07) -> Laps
Filter laps within a percentage of the fastest lap time.
threshold
float
default:"1.07"
Percentage threshold (1.07 = within 107% of best time)
Returns: Filtered Laps object Example:
# Get laps within 107% of best time
quick_laps = laps.pick_quicklaps()
# Get laps within 105% of best time
very_quick = laps.pick_quicklaps(1.05)

pick_tyre / pick_compounds

laps.pick_tyre(compound) -> Laps
laps.pick_compounds(compounds) -> Laps
Filter laps by tyre compound.
compound
str
required
Tyre compound (e.g., “SOFT”, “MEDIUM”, “HARD”)
compounds
list[str]
required
List of tyre compounds
Returns: Filtered Laps object Example:
soft_laps = laps.pick_tyre("SOFT")
slick_laps = laps.pick_compounds(["SOFT", "MEDIUM", "HARD"])

pick_track_status

laps.pick_track_status(status, how="equals") -> Laps
Filter laps by track status.
status
str
required
Track status code
how
Literal['equals', 'contains']
default:"equals"
Matching method: “equals” for exact match, “contains” for substring
Returns: Filtered Laps object Example:
green_flag = laps.pick_track_status("1", how="equals")
yellow_flags = laps.pick_track_status("4", how="contains")

pick_wo_box

laps.pick_wo_box() -> Laps
Filter laps without pit stops (wo = without box). Returns: Filtered Laps object excluding laps with pit in/out times

pick_box_laps

laps.pick_box_laps(which="both") -> Laps
Filter laps with pit stops.
which
Literal['in', 'out', 'both']
default:"both"
Type of pit laps: “in” (pit entry), “out” (pit exit), or “both”
Returns: Filtered Laps object Example:
# All pit laps
pit_laps = laps.pick_box_laps()
# Only pit entry laps
pit_in = laps.pick_box_laps("in")
# Only pit exit laps
pit_out = laps.pick_box_laps("out")

pick_not_deleted

laps.pick_not_deleted() -> Laps
Filter out deleted laps. Returns: Filtered Laps object excluding deleted laps

pick_accurate

laps.pick_accurate() -> Laps
Filter for accurate laps only. Returns: Filtered Laps object with IsAccurate=True

get_telemetry / get_car_data / get_pos_data

laps.get_telemetry() -> Telemetry
laps.get_car_data() -> Telemetry
laps.get_pos_data() -> Telemetry
Get telemetry data for the laps. All three methods return the same data. Returns: Telemetry DataFrame with telemetry from all laps Raises:
  • ValueError: If laps contain multiple drivers
Example:
ver_laps = laps.pick_driver("VER").pick_quicklaps()
tel = ver_laps.get_telemetry()

get_weather_data

laps.get_weather_data() -> DataFrame
Get weather data for the session. Returns: Weather DataFrame from the parent session

split_qualifying_sessions

laps.split_qualifying_sessions() -> tuple[Laps, Laps, Laps]
Split laps into Q1, Q2, Q3 sessions. Note: Tracing Insights data does not provide explicit Q1/Q2/Q3 splits, so this returns three copies of the same laps. Returns: Tuple of (Q1_laps, Q2_laps, Q3_laps)

iterlaps

laps.iterlaps(require=None) -> Generator[_IterLapResult, None, None]
Iterate over laps, yielding (index, lap) tuples.
require
list[str]
default:"None"
Required columns that must not be NaN. Defaults to [“LapTime”, “Driver”].
Returns: Generator yielding _IterLapResult tuples with .index and .lap properties Example:
for item in laps.iterlaps():
    print(f"Index: {item.index}, Driver: {item.lap['Driver']}, Time: {item.lap['LapTime']}")
    # Can also access by string key
    print(f"Lap number: {item['LapNumber']}")

Usage Examples

Basic Filtering

import tif1

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

# Single driver
ver_laps = laps.pick_driver("VER")

# Multiple drivers
top3 = laps.pick_drivers(["VER", "HAM", "LEC"])

# Specific lap number
lap_1 = laps.pick_lap(1)

# Lap range
first_10 = laps.pick_laps(slice(1, 10))

Advanced Filtering

# VER's quick laps on soft tyres without pit stops
filtered = (laps
    .pick_driver("VER")
    .pick_tyre("SOFT")
    .pick_quicklaps(1.05)
    .pick_wo_box()
    .pick_accurate()
)

print(f"Found {len(filtered)} qualifying laps")

Analyzing Lap Times

laps = session.laps

# Get fastest lap overall
fastest = laps.pick_fastest()
if fastest is not None:
    print(f"Overall fastest: {fastest['Driver']} - {fastest['LapTime']}")

# Get fastest lap per driver
for driver_code in session.drivers:
    driver_laps = laps.pick_driver(driver_code)
    fastest = driver_laps.pick_fastest()
    if fastest is not None:
        print(f"{driver_code}: {fastest['LapTime']}")

Pit Stop Analysis

# Laps with pit stops
pit_laps = laps.pick_box_laps()
print(f"Total pit stops: {len(pit_laps)}")

# Analyze pit in laps
pit_in_laps = laps.pick_box_laps("in")
for driver_code in session.drivers:
    driver_pit_ins = pit_in_laps.pick_driver(driver_code)
    print(f"{driver_code}: {len(driver_pit_ins)} pit stops")

Tyre Strategy

laps = session.laps

# Analyze compounds
for compound in ["SOFT", "MEDIUM", "HARD"]:
    compound_laps = laps.pick_tyre(compound)
    if len(compound_laps) > 0:
        avg_time = compound_laps['LapTime'].mean()
        print(f"{compound}: {len(compound_laps)} laps, avg {avg_time:.3f}s")

Telemetry Access

# Get telemetry for VER's quick laps
ver_quick = laps.pick_driver("VER").pick_quicklaps(1.05)
tel = ver_quick.get_telemetry()

if not tel.empty:
    print(f"Telemetry samples: {len(tel)}")
    print(f"Max speed: {tel['Speed'].max():.1f} km/h")

Iterating Over Laps

ver_laps = laps.pick_driver("VER")

for item in ver_laps.iterlaps():
    lap_num = item['LapNumber']
    lap_time = item['LapTime']
    compound = item['Compound']
    print(f"Lap {lap_num}: {lap_time} on {compound}")

See Also

Build docs developers (and LLMs) love