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.

Get up and running with tif1 quickly. This guide walks you through installation, basic usage, and common operations.

Installation

Install tif1 using pip:
pip install tif1
For optimal performance, consider installing the polars backend: pip install tif1[polars]

Your First Script

1

Import tif1

import tif1
2

Get a session

Fetch a Formula 1 session:
# Get the 2021 Belgian Grand Prix Race
session = tif1.get_session(2021, "Belgian Grand Prix", "Race")
No need to call session.load() - data is fetched lazily when you access it
3

Access lap data

Get lap times and information:
# Get all laps
laps = session.laps
print(laps.head())

# Get driver list
print(session.drivers_df)
4

Analyze telemetry

Access telemetry for specific laps:
# Get a specific driver
ver = session.get_driver("VER")

# Get telemetry for lap 19
lap = ver.get_lap(19)
telemetry = lap.telemetry
print(telemetry[["Time", "Speed", "Throttle"]].head())

Common Operations

Getting Events and Sessions

import tif1

# Get all events for a year
events = tif1.get_events(2024)
print(events)  # DataFrame with all 2024 races

# Get sessions for a specific event
sessions = tif1.get_sessions(2024, "Monaco Grand Prix")
print(sessions)  # ['Practice 1', 'Practice 2', 'Practice 3', 'Qualifying', 'Race']

Working with Drivers

# Get a specific driver's data
ham = session.get_driver("HAM")
ham_laps = ham.laps

# Get fastest lap for a driver
fastest = ham.get_fastest_lap()
print(f"Fastest lap: {fastest['LapTime'].iloc[0]}")

# Get fastest lap telemetry
fastest_tel = ham.get_fastest_lap_tel()
print(fastest_tel[["Speed", "Throttle", "Brake"]].head())

Filtering Laps

# Filter laps by driver
ver_laps = laps.pick_driver("VER")

# Get fastest laps per driver
fastest_laps = session.get_fastest_laps(by_driver=True)

# Filter by tire compound
soft_laps = laps.pick_tyre("SOFT")

# Exclude pit laps
racing_laps = laps.pick_wo_box()

Comparing Telemetry

# Get fastest laps for two drivers
ver_fastest = session.get_driver("VER").get_fastest_lap()
ham_fastest = session.get_driver("HAM").get_fastest_lap()

# Get their telemetry
ver_tel = ver_fastest.get_telemetry()
ham_tel = ham_fastest.get_telemetry()

# Compare speeds
import matplotlib.pyplot as plt

plt.plot(ver_tel["Distance"], ver_tel["Speed"], label="VER")
plt.plot(ham_tel["Distance"], ham_tel["Speed"], label="HAM")
plt.legend()
plt.xlabel("Distance (m)")
plt.ylabel("Speed (km/h)")
plt.show()

Complete Example

Here’s a complete example that analyzes qualifying performance:
import tif1

# Get qualifying session
quali = tif1.get_session(2024, "Monaco Grand Prix", "Qualifying")

# Get fastest lap per driver in Q3
fastest_laps = quali.get_fastest_laps(by_driver=True)

# Sort by lap time
fastest_laps = fastest_laps.sort_values("LapTimeSeconds")

# Display top 10
print(fastest_laps[["Driver", "LapTime", "Compound", "Team"]].head(10))

# Get pole position driver
pole_driver = fastest_laps.iloc[0]["Driver"]
pole_lap = fastest_laps.iloc[0]

print(f"\nPole position: {pole_driver}")
print(f"Time: {pole_lap['LapTime']}")
print(f"Tire: {pole_lap['Compound']}")

# Get pole lap telemetry
pole_tel = quali.get_driver(pole_driver).get_lap(
    int(pole_lap['LapNumber'])
).get_telemetry()

# Analyze the pole lap
max_speed = pole_tel["Speed"].max()
avg_throttle = pole_tel["Throttle"].mean()

print(f"Max speed: {max_speed:.1f} km/h")
print(f"Avg throttle: {avg_throttle:.1f}%")
     Driver       LapTime Compound          Team
0       VER  0 days 00:01:10.270     SOFT   Red Bull Racing
1       LEC  0 days 00:01:10.312     SOFT        Ferrari
2       SAI  0 days 00:01:10.345     SOFT        Ferrari
...

Pole position: VER
Time: 0 days 00:01:10.270000
Tire: SOFT
Max speed: 290.5 km/h
Avg throttle: 73.2%

Performance Tips

Use Caching

Data is automatically cached in SQLite. Second access is 10-100x faster.

Async Loading

Use async methods for parallel data fetching:
tels = session.get_fastest_laps_tels(by_driver=True)
# Fetches 20 telemetry files in parallel - 4-5x faster

Polars Backend

Switch to polars for 2x faster operations:
# In .tif1rc
{"backend": "polars"}

Filter Early

Filter laps before loading telemetry to reduce data transfer

Next Steps

Core Concepts

Understand sessions, laps, drivers, and data flow

Guides

Learn specific techniques for data analysis

API Reference

Explore the complete API documentation

Examples

See real-world analysis examples

Debug Mode

If you encounter issues, enable debug logging:
import tif1
import logging

tif1.setup_logging(logging.DEBUG)

# Your code here - detailed logs will be printed
session = tif1.get_session(2024, "Monaco Grand Prix", "Race")

Need Help?

fastf1 Migration

Migrating from fastf1? Check our compatibility guide

Build docs developers (and LLMs) love