What is a Session?
A Session is the fundamental data container in tif1, representing a single Formula 1 track session. Each session corresponds to one on-track activity during a Grand Prix weekend. Examples are Practice 1, Qualifying, Sprint, or the Race. The Session object is the primary interface for access to all F1 data associated with that particular session. It provides a unified, high-performance API for data retrieval.- Driver information - Complete roster of participating drivers with team affiliations, driver numbers, names, and metadata
- Lap data - Comprehensive lap-by-lap information for all drivers including lap times, sectors, tire compounds, track status, and more
- Telemetry data - High-frequency sensor data capturing speed, throttle, brake, RPM, gear, DRS, and 3D position coordinates
- Weather conditions - Time-series weather data including air temperature, track temperature, humidity, wind, and rainfall
- Race control messages - Official FIA communications including flags, penalties, safety car periods, and track status changes
- Session results - Final classification, grid positions, and driver standings
- Circuit information - Track layout data including corner positions, angles, and circuit rotation
Session Data Hierarchy
The Session data hierarchy supports efficient navigation and access to the required information.Data Organization
The Session object organizes data in a logical hierarchy:- Session Level - Top-level metadata, configuration, and session-wide data (weather, race control messages)
- Driver Level - Individual driver information, complete lap history for each driver
- Lap Level - Single lap data including lap time, sectors, tire compound, track status
- Telemetry Level - High-frequency sensor data for a specific lap (typically 100-300 Hz sampling rate)
Creating a Session
The primary way to create a Session object is through theget_session() function. This function accepts flexible parameters that identify the exact session for analysis.
Basic Session Creation
Performance Optimization with Polars
For maximum performance, tif1 supports Polars as an alternative DataFrame backend. Polars provides 2-3x faster data processing compared to pandas, especially for large datasets.Polars must be installed separately:
pip install polars>=1.40.1. If Polars is not available, tif1 automatically falls back to pandas with a warning.Cache Control
By default, tif1 caches all fetched data to disk for instant subsequent access. Control the caching behavior for each session:Global Configuration
Set default values forlib and enable_cache globally with the config system:
Session Properties
Session properties provide read-only access to various data types. All properties use lazy loading. Data is fetched only on first access to the property.drivers
Returns a list of driver numbers as strings. This property provides FastF1 API compatibility.list[str] - List of driver numbers as strings
driver_list
Alias fordrivers property. Returns the same list of driver numbers.
list[str] - List of driver numbers as strings
drivers_df
Returns comprehensive driver information as a DataFrame. This is the most detailed driver data available, including names, teams, colors, and headshot URLs.pandas.DataFrame - DataFrame with 7 columns (Driver, Team, DriverNumber, FirstName, LastName, TeamColor, HeadshotUrl)
laps
Returns all laps for all drivers in the session. This is one of the most important properties, containing comprehensive lap-by-lap data. Key Features:- Automatically includes weather data merged with each lap
- Contains sector times, lap times, tire compounds, track status
- Includes position data, pit stop information, and more
- Returns pandas or Polars DataFrame depending on session configuration
DataFrame (pandas or Polars) - All laps with weather data merged
weather
Returns time-series weather data recorded throughout the session. Weather data is sampled at regular intervals (typically every 1-2 minutes).DataFrame (pandas or Polars) - Weather data time series
Weather data is automatically merged into the
laps DataFrame, so each lap has associated weather conditions. Direct access to session.weather is necessary only for independent analysis of weather trends.weather_data
Alias for theweather property. Provides FastF1 API compatibility.
DataFrame (pandas or Polars) - Weather data time series
race_control_messages
Returns official FIA race control messages issued during the session. These messages include flags, penalties, investigations, safety car periods, and other official communications.DataFrame (pandas or Polars) - Race control messages
results
Returns session results with final classification and driver information. This property provides a FastF1-compatibleSessionResults object.
SessionResults (pandas DataFrame subclass) - Session results
car_data
Returns complete telemetry data for all drivers across all laps. This is a very large dataset that contains high-frequency sensor data.DataFrame (pandas or Polars) - Complete telemetry for all drivers
pos_data
Alias forcar_data. Returns the same complete telemetry dataset.
DataFrame (pandas or Polars) - Complete telemetry for all drivers
session_info
Returns basic session metadata as a dictionary.dict[str, Any] - Session metadata
name
Returns the human-readable session name (URL-decoded).str - Session name
date
Returns the session date as a pandas Timestamp.pandas.Timestamp or pd.NaT - Session date
event
Returns the Event object for this session’s Grand Prix. The Event object contains schedule information for all sessions in the weekend.Event - Event object for the Grand Prix weekend
Session Methods
Session methods provide powerful functionality for data analysis, filtering, and retrieval.load()
Explicitly load session data with fine-grained control over what gets fetched. This method is useful to pre-fetch data or to control exactly what data is loaded. Signature:laps(bool): If True, fetch laps data. Default: Truetelemetry(bool): If True, fetch telemetry for all laps. Automatically sets laps=True. Default: Trueweather(bool): If True, fetch weather data. Default: Truemessages(bool): If True, fetch race control messages. Default: True
Session - Returns self for method chaining
Examples:
When
telemetry=True is requested but laps=False, the method automatically sets laps=True because telemetry requires lap data to function properly.get_driver()
Get a Driver object for a specific driver. The Driver object provides convenient access to that driver’s laps and telemetry. Signature:driver_code(str): 3-letter driver code (for example, ‘VER’, ‘HAM’, ‘LEC’)
Driver - Driver object with laps and telemetry access
Examples:
get_fastest_laps()
Get the fastest lap(s) from the session. This method can return either the fastest lap per driver or the single overall fastest lap. Signature:by_driver(bool): If True, return fastest lap per driver. If False, return single overall fastest lap. Default: Truedrivers(list[str] | None): Optional list of driver codes to filter. If None, includes all drivers. Default: None
DataFrame - Fastest lap(s) with all lap data columns
Examples:
This method only considers valid laps (not deleted laps). Deleted laps are automatically filtered out.
get_fastest_lap_tel()
Get telemetry for the overall fastest lap in the session. This is a convenience method that combines finding the fastest lap and fetching its telemetry. Signature:DataFrame - Telemetry data for the fastest lap
Examples:
get_fastest_laps_tels()
Fetch telemetry for multiple drivers’ fastest laps in parallel. This is significantly faster than fetching telemetry sequentially. Signature:by_driver(bool): If True, fetch telemetry for each driver’s fastest lap. If False, fetch only the overall fastest lap. Default: Truedrivers(list[str] | None): Optional list of driver codes to filter. If None, includes all drivers. Default: None
dict[str, DataFrame] - Dictionary mapping driver codes to their fastest lap telemetry
Examples:
This method uses asynchronous parallel fetching internally, which makes it much faster than calling
get_driver(driver).laps.fastest().telemetry for each driver sequentially.laps_async()
Asynchronously load all laps for maximum performance. This method is useful for integration of tif1 into an async application. It also gives the absolute fastest lap loading. Signature:DataFrame - All laps (same as session.laps property)
Examples:
get_circuit_info()
Get circuit layout information including corner positions, angles, and track rotation. Signature:CircuitInfo - Dataclass with circuit information
CircuitInfo Attributes:
corners(DataFrame): Corner data with columns X, Y, Number, Letter, Angle, Distancemarshal_lights(DataFrame): Marshal light positions (always empty - not in source data)marshal_sectors(DataFrame): Marshal sector boundaries (always empty - not in source data)rotation(float): Circuit rotation in degrees
Circuit information is cached after the first call, so subsequent calls are instant.
fetch_all_laps_telemetry()
Fetch telemetry for all laps of all drivers. This is equivalent to accessingsession.car_data but provides explicit control.
Signature:
DataFrame - Complete telemetry for all drivers and laps
Examples:
Session Types and Formats
tif1 supports all official Formula 1 session types across different weekend formats.Standard Race Weekend
A typical F1 race weekend consists of:- Practice 1 (FP1) - Friday morning, 60 minutes
- Practice 2 (FP2) - Friday afternoon, 60 minutes
- Practice 3 (FP3) - Saturday morning, 60 minutes
- Qualifying (Q) - Saturday afternoon, ~60 minutes (Q1, Q2, Q3)
- Race (R) - Sunday, ~2 hours
Sprint Weekend
Sprint weekends have a modified format:- Practice 1 (FP1) - Friday, 60 minutes
- Sprint Qualifying (SQ) - Friday, ~60 minutes (SQ1, SQ2, SQ3)
- Sprint (S) - Saturday, ~30 minutes (~100km race)
- Qualifying (Q) - Saturday, ~60 minutes (Q1, Q2, Q3)
- Race (R) - Sunday, ~2 hours
Session Name Variations
tif1 accepts multiple variations of session names for convenience:Data Loading Architecture
Knowledge of the tif1 data loading process helps with performance optimization and troubleshooting.Lazy Loading
Sessions use lazy loading for optimal performance. When a Session object is created, no data is fetched immediately. Data is retrieved only on explicit access.- Fast initialization - Session objects are created instantly
- Efficient memory usage - Only requested data is loaded
- Flexible workflows - Load only the data that the analysis requires
- Reduced network traffic - Avoid fetching unused data
Caching Strategy
tif1 implements a multi-tier caching system for maximum performance:1. Memory Cache (L1)
- In-memory storage of fetched data within the Session object
- Fastest access (nanoseconds)
- Cleared when Session object is destroyed
- Automatic and transparent
2. Persistent Cache (L2)
- SQLite-based disk cache in the tif1 OS-dependent cache directory (configurable via
TIF1_CACHE_DIR) - Survives across Python sessions
- Shared between all tif1 sessions
- Configurable via
enable_cacheparameter
3. CDN (L3)
- Three-source CDN chain (jsDelivr, Hugging Face buckets, StaticDelivr) serving TracingInsights data repositories
- Fetched only on cache miss
- Automatic retry with exponential backoff
- Multiple CDN sources for redundancy
Session Loading Flow
Ultra-Cold Start Optimization
For specific use cases, tif1 provides ultra-cold start mode. This aggressive optimization bypasses normal caching and validation for maximum speed.- Real-time applications requiring minimum latency
- One-off queries where caching is not beneficial
- Benchmarking and performance testing
- Live timing applications
- Skips data validation (assumes CDN data is correct)
- Bypasses retry logic (one try only)
- No persistent caching (unless background fill is enabled)
Parallel Fetching
tif1 automatically uses parallel fetching for operations that require multiple network requests:- 10-20x faster for multi-driver operations
- Efficient use of network bandwidth
- Automatic connection pooling
- Configurable concurrency limits
Prefetching Strategies
tif1 implements intelligent prefetching to reduce latency:Session Table Prefetching
Driver Lap Prefetching
Background Telemetry Prefetching
Data Enrichment and Transformations
tif1 automatically enriches and transforms raw F1 data to make it more useful for analysis.Automatic Weather Merging
Weather data is automatically merged into every lap, eliminating the need for manual joins:Computed Columns
tif1 adds computed columns for convenience:LapTimeSeconds
Numeric representation of lap time for easier calculations:DriverAhead and DistanceToDriverAhead
Telemetry includes relative position data:Column Renaming and Standardization
tif1 renames columns from the raw CDN format to more intuitive names:Type Conversions
tif1 automatically converts data types for optimal performance and usability:Data Validation
tif1 validates data integrity and handles edge cases:- Missing data - Replaced with appropriate null values (NaN, NaT, None)
- Invalid lap times - Filtered out or marked as deleted
- Malformed telemetry - Logged and skipped
- Inconsistent driver codes - Normalized to 3-letter format
- Out-of-range values - Clamped or marked as invalid
Performance Optimization Tips
Maximize tif1 performance with these best practices:1. Use Polars for Large Datasets
Polars provides 2-3x faster data processing:2. Load Only the Required Data
Use theload() method to control data fetching:
3. Use Driver-Specific Access
Avoid loading all laps when only one driver is needed:4. Use Parallel Fetching
Use methods that fetch in parallel:5. Enable Caching
Always use caching unless there is a specific reason not to:6. Reuse Session Objects
Create session objects once and reuse them:7. Filter Early
Filter DataFrames as early as possible:8. Use Ultra-Cold Start for One-Off Queries
For single-use queries, enable ultra-cold start:9. Avoid Repeated Telemetry Fetches
Cache telemetry results when analyzing multiple laps:10. Monitor Cache Size
Periodically clear cache if disk space is a concern:Common Patterns and Examples
Pattern: Compare Fastest Laps
Pattern: Analyze Tire Degradation
Pattern: Weather Impact Analysis
Pattern: Sector Analysis
Pattern: Overtaking Analysis
Pattern: Telemetry Heatmap
Troubleshooting
Issue: Slow Data Loading
Symptoms: First access tosession.laps takes a long time
Solutions:
- Check the internet connection
- Verify CDN is accessible:
tif1.cdn.test_connection() - Enable ultra-cold start for faster initial fetch
- Use Polars backend for faster parsing
Issue: Cache Not Working
Symptoms: Data is fetched from CDN every time Solutions:- Verify caching is enabled:
session.enable_cache - Check that the platform-specific cache directory exists
- Verify disk space is available
- Clear corrupted cache:
tif1.cache.clear()
Issue: Missing Data
Symptoms: Empty DataFrames or missing columns Solutions:- Verify session exists: Check F1 calendar
- Check for typos in event/session names
- Some sessions may not have all data types (for example, no telemetry for old seasons)
- Use
session.driversto verify drivers are present
Issue: Memory Usage
Symptoms: High memory consumption Solutions:- Use Polars backend (more memory efficient)
- Load only required data with
session.load() - Access driver-specific data instead of all laps
- Avoid loading
session.car_data(very large) - Process data in chunks
Issue: Telemetry Not Available
Symptoms: Empty telemetry DataFrames Solutions:- Verify telemetry exists for that session/driver
- Check for deleted laps (no telemetry for deleted laps)
- Some drivers may not have telemetry for all laps
- Check logs for telemetry fetch failures
Related Pages
Core API
Complete Session class API reference.
Getting Started
Quick start guide and installation.
Data Flow
The tif1 data pipeline.
Caching Strategy
Details of the caching architecture.
Backends
Pandas vs Polars comparison.
Race Analysis Tutorial
Step-by-step race analysis guide.