import tif1# Load the 2025 monaco grand prix racesession = tif1.get_session(2025, "Monaco Grand Prix", "Race")print(f"Loaded session: {session.event} {session.session_type}")
The first time you load a session, tif1 fetches data from the CDN. Subsequent loads are instant thanks to caching.
# Get all lapslaps = session.laps# Show fastest lapsfastest = laps.nsmallest(10, "LapTime")print(fastest[["Driver", "LapNumber", "LapTime", "Compound"]])
import tif1# List all events in 2025events = tif1.get_events(2025)print(f"Found {len(events)} events")# List sessions for an eventsessions = tif1.get_sessions(2025, "Monaco Grand Prix")print(f"Available sessions: {sessions}")
# Group by driver and stintstrategy = laps.groupby(["Driver", "Stint"]).agg({ "Compound": "first", "LapNumber": ["min", "max", "count"]}).reset_index()print(strategy)
# Get weather dataweather = session.weather# Check for rainif weather["Rainfall"].any(): print("Rain detected during session") rain_laps = weather[weather["Rainfall"]]["Time"] print(f"Rain from {rain_laps.min():.0f}s to {rain_laps.max():.0f}s")
# Fetch all telemetry in parallel (28x faster)tels = session.get_fastest_laps_tels(by_driver=True)for driver, tel in tels.items(): print(f"{driver}: {tel['Speed'].max()} km/h")
import matplotlib.pyplot as plt# Plot lap timeslaps = session.lapsver_laps = laps[laps["Driver"] == "VER"]plt.figure(figsize=(12, 6))plt.plot(ver_laps["LapNumber"], ver_laps["LapTime"], marker="o")plt.xlabel("Lap Number")plt.ylabel("Lap Time (s)")plt.title("VER Lap Times - Monaco 2025")plt.grid(True, alpha=0.3)plt.show()
# Use polars (50% less memory)session = tif1.get_session(2025, "Monaco", "Race", lib="polars")# Or process drivers one at a timefor driver_code in session.drivers: driver = session.get_driver(driver_code) laps = driver.laps # Process laps del laps # Free memory