The events module is your gateway to discovering and navigating Formula 1 calendar data. It provides a rich, type-safe API for querying event schedules, session timings, and comprehensive metadata across multiple seasons, serving as the foundation for all data discovery operations in
tif1.Overview
The events module provides a comprehensive, production-ready set of functions and classes for discovering what Formula 1 data is available in the TracingInsights CDN for specific years and events. This module serves as the primary entry point for event discovery and session navigation intif1, enabling sophisticated workflows for data analysis, visualization, and automation.
Core Capabilities
The events API empowers you to:- Query season schedules: Retrieve complete event calendars for any supported F1 season (2018-present) with full metadata including event names, locations, countries, dates, and formats
- Discover available sessions: Programmatically determine which sessions (Practice 1-3, Qualifying, Sprint Qualifying, Sprint, Race) have data available for each event
- Access rich event metadata: Get detailed information about each Grand Prix including official event names (with sponsors), circuit locations, round numbers, event dates, and weekend formats
- Navigate flexibly: Use intelligent fuzzy matching to find events by partial names, abbreviations, circuit names, or round numbers without requiring exact string matches
- Work with timezone-aware data: Access session start times in both local circuit timezone and UTC, enabling accurate time-based analysis and scheduling
- Handle different event formats: Seamlessly work with conventional race weekends (3 practice sessions), sprint weekends (varied formats by year), and pre-season testing events
- Leverage pandas integration: Work with familiar DataFrame and Series interfaces enhanced with domain-specific methods for F1 data navigation
- Benefit from intelligent caching: All schedule data is cached in-memory after first fetch, making subsequent queries instant with zero network overhead
Architecture & Design Philosophy
The events module is built on several key design principles:- Performance-First: Aggressive caching strategies ensure that schedule queries complete in <10ms after initial load. The module uses vendored JSON files for recent seasons and CDN fallback for historical data.
- Pandas Integration: All data structures extend pandas DataFrame and Series, providing familiar interfaces while adding F1-specific methods. This enables seamless integration with the broader pandas ecosystem.
- Flexible Querying: Multiple lookup methods (by round number, by name, by fuzzy match) ensure you can query data in the most natural way for your use case, whether programmatic or interactive.
- Type Safety: Full type hints throughout the API enable excellent IDE autocomplete and static type checking with mypy or pyright.
- Graceful Degradation: The module handles missing data, network failures, and edge cases gracefully, providing clear error messages and fallback behaviors.
Data Sources & Availability
Schedule data is sourced from two primary locations:- Vendored JSON files: Recent seasons (typically current and previous year) are packaged with
tif1for instant access without network requests - TracingInsights CDN: Historical seasons are fetched from the TracingInsights GitHub data repositories via the jsdelivr CDN
- All championship Grand Prix events
- Pre-season testing events (optional, can be filtered)
- Sprint weekend events with correct session formats
- Session names and availability
- Event metadata (names, locations, countries, dates, formats)
- Session timing information (local and UTC)
Core Functions
get_events
EventSchedule object, which is a specialized pandas DataFrame subclass that includes additional methods for event lookup and filtering. Each row in the DataFrame represents a single Grand Prix event with comprehensive metadata including event names, locations, dates, session schedules, and format information.
Parameters:
int
required
The Formula 1 season year to query. Must be between 2018 and the current year (2026). Years outside this range will raise a
DataNotFoundError as schedule data is not available.Supported years: 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025, 2026EventSchedule
A pandas DataFrame subclass containing all events for the specified year. The DataFrame includes the following columns:
EventName: Official short name (e.g., “Belgian Grand Prix”)Location: Circuit or venue name (e.g., “Spa-Francorchamps”)OfficialEventName: Full official event title with sponsorsRoundNumber: Championship round number (1-indexed)Country: Country where the event takes placeEventDate: Main event date (typically race day)EventFormat: Format type (“conventional”, “sprint”, or “testing”)Session1,Session2, …: Names of available sessionsSession1Date,Session2Date, …: Local session start times with timezoneSession1DateUtc,Session2DateUtc, …: UTC session start times
get_event_by_round() and get_event_by_name() for convenient event lookup.DataNotFoundError: If schedule data is not available for the specified yearNetworkError: If the CDN request fails and no cached data is availableInvalidDataError: If the schedule data is malformed or cannot be parsed
- Caching: Schedule data is cached in-memory after the first request. Subsequent calls for the same year return cached data instantly without network requests.
- Data Source: Schedule data is fetched from the TracingInsights CDN (via jsdelivr) or loaded from vendored JSON files included with the package for recent seasons.
- Testing Events: By default,
get_events()includes all events including pre-season testing. Useget_event_schedule(year, include_testing=False)if you want to exclude testing events. - Performance: This function is highly optimized and typically completes in <10ms for cached data or <200ms for initial CDN fetch.
get_sessions
- Conventional weekends: Typically include Practice 1, Practice 2, Practice 3, Qualifying, and Race
- Sprint weekends: May include Practice 1, Sprint Qualifying, Sprint, Qualifying, and Race (format varies by year)
- Testing events: Usually include multiple test sessions
int
required
The Formula 1 season year. Must be a valid year with available schedule data (2018-2026).
str
required
The Grand Prix event name. This should match the official event name (e.g., “Belgian Grand Prix”), but fuzzy matching is applied internally so partial names like “Belgian” will also work.Accepted formats:
- Full official name: “Belgian Grand Prix”
- Partial name: “Belgian”
- Case-insensitive: “belgian grand prix”, “BELGIAN GP”
list[str]
An ordered list of session names available for the specified event. Sessions are returned in chronological order (Practice 1 → Practice 2 → … → Race).Common session names:
"Practice 1","Practice 2","Practice 3""Qualifying""Sprint Qualifying","Sprint Shootout"(sprint weekend qualifying)"Sprint"(sprint race)"Race"(main Grand Prix)"Pre-Season Testing"(testing events)
DataNotFoundError: If the event is not found in the specified year’s scheduleNetworkError: If schedule data cannot be fetched and no cache is availableInvalidDataError: If the schedule data is malformed
- Fuzzy Matching: The function uses intelligent fuzzy matching to find events even with partial or misspelled names. For example, “Silverstone”, “British”, and “British Grand Prix” will all match the British Grand Prix.
- Caching: Session lists are cached after the first query, making subsequent calls instant.
- Data Availability: The returned list indicates which sessions have data available in the CDN. Just because a session is listed doesn’t guarantee all data types (laps, telemetry, etc.) are available for that session.
- Empty Lists: If an event has no sessions (rare edge case), an empty list is returned rather than raising an exception.
get_event
Event object is a pandas Series subclass that contains all event metadata and provides methods for accessing sessions, session timings, and other event-specific information.
Parameters:
int
required
The Formula 1 season year (2018-2026).
int | str
required
The Grand Prix identifier. Can be either:Round number (int):
- Championship round number (1-indexed)
- Example:
12for the 12th race of the season - Must be within the valid range for the season (typically 1-23)
- Full official name:
"Belgian Grand Prix" - Partial name:
"Belgian","Spa" - Case-insensitive:
"belgian grand prix","BELGIAN GP" - Abbreviations:
"BEL"(may work depending on fuzzy matching)
bool
default:"False"
Controls the string matching behavior when
gp is a string:False(default): Uses fuzzy matching algorithm to find the best match. Tolerates typos, partial names, and case variations.True: Requires an exact string match (case-sensitive). Use this when you need precise control or want to avoid ambiguous matches.
gp is an integer (round number).Event | None
An
Event object (pandas Series subclass) containing event metadata and methods for session access. Returns None if the event is not found and exact_match=False.When exact_match=True, raises DataNotFoundError instead of returning None.DataNotFoundError: If the event is not found andexact_match=True, or if the round number is invalidValueError: If the round number is out of range for the seasonNetworkError: If schedule data cannot be fetchedInvalidDataError: If the schedule data is malformed
- Fuzzy Matching Algorithm: Uses Levenshtein distance and token-based matching to find the closest event name. Handles common abbreviations, typos, and variations.
- Round Number Lookup: When
gpis an integer, performs direct index lookup in the schedule (O(1) operation). - Caching: Event objects are cached after creation, making repeated lookups instant.
- None vs Exception: With
exact_match=False, returnsNonefor not found. Withexact_match=True, raisesDataNotFoundError. Choose based on your error handling preference.
get_event_by_round
int
required
The Formula 1 season year (2018-2026). Must be a year with available schedule data.
int
required
The championship round number (1-indexed). Must be within the valid range for the specified season.Valid ranges by season:
- Most seasons: 1-22 or 1-23 rounds
- 2020 (COVID-affected): 1-17 rounds
- Check
len(tif1.get_events(year))for exact count
Event
An
Event object (pandas Series subclass) containing all event metadata and methods for session access. The Event object provides dictionary-style access to fields like EventName, Location, Country, RoundNumber, EventDate, EventFormat, and session information.ValueError: If the round number is out of range for the specified season (e.g., requesting round 25 when the season only has 22 rounds)DataNotFoundError: If schedule data is not available for the specified yearNetworkError: If schedule data cannot be fetched from the CDN and no cached data is available
- Performance: This is the fastest event lookup method, performing a direct index lookup in O(1) time. Use this when you know the round number.
- Reliability: Round numbers are unambiguous and don’t require any fuzzy matching or string comparison, making this the most reliable lookup method.
- Caching: Event objects are cached after creation, so repeated calls with the same parameters return instantly.
- Testing Events: Pre-season testing events typically don’t have round numbers and cannot be accessed via this function. Use
get_event_by_name()for testing events.
get_event_by_name
int
required
The Formula 1 season year (2018-2026). Must be a year with available schedule data.
str
required
The event name or partial name to search for. The function accepts multiple formats:Full official names:
"Belgian Grand Prix""British Grand Prix""Monaco Grand Prix"
"Belgian"→ matches “Belgian Grand Prix”"British"→ matches “British Grand Prix”"Monaco"→ matches “Monaco Grand Prix”
"Spa"→ matches “Belgian Grand Prix” (Spa-Francorchamps)"Silverstone"→ matches “British Grand Prix”"Monza"→ matches “Italian Grand Prix”
"belgian grand prix","BELGIAN GP","Belgian"all work
"Pre-Season Testing"or"Testing"for test sessions
bool
default:"False"
Controls the string matching behavior:
-
False(default): Uses fuzzy matching algorithm to find the best match. Tolerates typos, partial names, case variations, and common abbreviations. -
True: Requires an exact string match (case-sensitive). The provided name must match the official event name character-for-character.
- Validating user input against known event names
- Ensuring no false positives in automated systems
- When you have the exact official event name
- Interactive applications where users type event names
- When accepting partial or abbreviated input
- When you want maximum flexibility
Event
An
Event object (pandas Series subclass) containing all event metadata and methods for session access.DataNotFoundError: If the event is not found in the specified year’s scheduleNetworkError: If schedule data cannot be fetched from the CDN and no cached data is availableInvalidDataError: If the schedule data is malformed or cannot be parsed
- Fuzzy Matching Algorithm: Uses a combination of Levenshtein distance (edit distance) and token-based matching to find the closest event name. The algorithm tokenizes both the search query and event names, compares tokens, and calculates similarity scores.
-
Match Scoring: The fuzzy matcher assigns a similarity score to each event name. The event with the highest score above a threshold is returned. If no event scores above the threshold,
DataNotFoundErroris raised. - Performance: Fuzzy matching is more expensive than round number lookup but still completes in <5ms for cached schedules. The algorithm iterates through all events in the season (typically 20-23 events).
- Caching: Event objects are cached after creation. The fuzzy matching itself is not cached, so each call performs the matching algorithm, but the resulting Event object is reused.
get_event_schedule
EventSchedule object is a specialized pandas DataFrame subclass that includes all the standard DataFrame functionality plus additional F1-specific methods for event lookup and filtering. Each row represents a single Grand Prix event with comprehensive metadata.
Parameters:
int
required
The Formula 1 season year (2018-2026). Must be a year with available schedule data.
bool
default:"True"
Controls whether pre-season testing events are included in the returned schedule.
True(default): Includes all events including pre-season testing sessionsFalse: Excludes testing events, returning only championship Grand Prix events
- Championship analysis (only counting points-scoring events)
- Season statistics (excluding non-competitive sessions)
- Calendar visualization (showing only race weekends)
- Complete data availability overview
- Pre-season analysis and testing data
- Comprehensive event iteration
EventSchedule
An
EventSchedule object (pandas DataFrame subclass) containing all events for the specified year. The DataFrame includes the following columns:Core Event Information:EventName: Official short name (e.g., “Belgian Grand Prix”)Location: Circuit or venue name (e.g., “Spa-Francorchamps”)OfficialEventName: Full official event title with sponsors (e.g., “FORMULA 1 ROLEX BELGIAN GRAND PRIX 2021”)RoundNumber: Championship round number (1-indexed integer)Country: Country where the event takes place (e.g., “Belgium”)EventDate: Main event date as pandas Timestamp (typically race day)EventFormat: Format type - one of “conventional”, “sprint”, or “testing”
Session1,Session2,Session3,Session4,Session5: Names of available sessions (e.g., “Practice 1”, “Qualifying”, “Race”)Session1Date,Session2Date, …: Local session start times with timezone informationSession1DateUtc,Session2DateUtc, …: UTC session start times as pandas Timestamps
get_event_by_round(round_number): Get a specific event by round numberget_event_by_name(name, strict_search=False): Get a specific event by name with optional fuzzy matchingget_event(identifier, strict_search=False): Get an event by either round number or name
DataNotFoundError: If schedule data is not available for the specified yearNetworkError: If the CDN request fails and no cached data is availableInvalidDataError: If the schedule data is malformed or cannot be parsed
- Data Source: Schedule data is fetched from vendored JSON files (for recent seasons) or the TracingInsights CDN (for historical seasons). The data source is transparent to the user.
-
Caching: Schedule data is cached in-memory after the first request. Subsequent calls for the same year and
include_testingvalue return cached data instantly. -
Testing Events: Testing events typically have
EventFormat="testing"and may not have aRoundNumber. They usually appear at the beginning of the season (pre-season testing). -
Session Columns: The number of session columns varies by event format. Conventional weekends typically have 5 sessions (FP1, FP2, FP3, Q, R), while sprint weekends may have different configurations. Unused session columns contain
NaNor empty strings. - Timezone Handling: Session dates include timezone information. Local times use the circuit’s timezone (e.g., “Europe/Brussels” for Spa), while UTC times are timezone-aware UTC timestamps.
- Performance: Initial load takes <200ms for CDN fetch or <10ms for vendored data. Cached access is <1ms.
The
get_events(year) function is an alias for get_event_schedule(year, include_testing=True). Both return the same EventSchedule object. Use whichever name is more intuitive for your use case.Event
TheEvent class is a pandas Series subclass representing a single Grand Prix event with metadata and session access.
Properties
int
The season year (read-only property).
Series Data Fields
Access event data using dictionary-style indexing:str
The official event name (e.g., “Belgian Grand Prix”).
str
The event location (e.g., “Spa-Francorchamps”).
str
The full official event name (e.g., “FORMULA 1 ROLEX BELGIAN GRAND PRIX 2021”).
int
The championship round number.
str
The country where the event takes place.
pd.Timestamp
The main event date.
str
The event format (e.g., “conventional”, “sprint”).
str
Session names (e.g., “Practice 1”, “Qualifying”, “Race”).
datetime
Local session date/time with timezone.
pd.Timestamp
UTC session timestamps.
Methods
get_session(session_name)
session_name: Session identifier - can be:- Session name (e.g., “Qualifying”, “Race”)
- Session abbreviation (e.g., “Q”, “R”, “FP1”)
- Session number (e.g., 1, 2, 3)
Sessionobject ready to load data
ValueError: If the session identifier is invalid or doesn’t exist for this event
get_session_name(identifier)
identifier: Session number, abbreviation, or partial name
- Canonical session name
ValueError: If the identifier is invalid
get_session_date(identifier, utc=False)
identifier: Session name, abbreviation, or numberutc: IfTrue, return UTC timestamp. IfFalse, return local time with timezone
- Timestamp for the session
ValueError: If session doesn’t exist or local timestamp unavailable
get_race()
get_qualifying()
get_sprint()
get_sprint_shootout()
get_sprint_qualifying()
get_practice(number)
number: Practice session number (1, 2, or 3)
EventSchedule
TheEventSchedule class is a pandas DataFrame subclass containing all events for a season.
Properties
int | None
The season year.
Methods
get_event_by_round(round_number)
round_number: The round number (1-indexed)
Eventobject
ValueError: If the round number is invalid
get_event_by_name(name, strict_search=False)
name: Event namestrict_search: IfTrue, requires exact match
Eventobject orNoneif not found
get_event(identifier, strict_search=False)
identifier: Round number (int) or event name (str)strict_search: IfTrue, requires exact name match
Eventobject orNoneif not found
Session name formats
Whiletif1 is flexible with session names, use these standard formats for consistency:
tif1 uses fuzzy matching internally, so “P1”, “FP1”, and “Practice 1” all resolve to the same session. However, using standard names improves code clarity.Complete Examples
List all events and sessions
Work with event objects
Fuzzy event matching
Iterate through season
Multi-year comparison
Find events by criteria
Load all sessions for an event
Build a season calendar
Analyze sprint weekend evolution
Export season data to multiple formats
Build an event lookup CLI tool
Track calendar changes across years
Best Practices
Performance Optimization
1. Use round numbers when possible Round number lookups are O(1) operations and don’t require fuzzy matching:include_testing=False when appropriate
If you don’t need testing events, exclude them to reduce data size:
Error Handling
1. Always handle DataNotFoundError Event and session data may not always be available:Code Organization
1. Create helper functions for common patternsData Validation
1. Verify session availability before loadingTesting and Development
1. Use known events for testingCommon Patterns
Pattern: Season-wide analysis
Pattern: Event discovery workflow
Pattern: Batch processing
Troubleshooting
Issue: Event not found with fuzzy matching
Problem:get_event_by_name() raises DataNotFoundError even though the event exists.
Solution: The event name might be too generic or ambiguous. Try:
Issue: Session not available
Problem:get_session() raises ValueError for a session that should exist.
Solution: Check actual session availability:
Issue: Network errors
Problem:NetworkError when fetching schedule data.
Solution: The CDN might be unavailable. Recent years use vendored data:
Issue: Incorrect round numbers
Problem: Round numbers don’t match expectations. Solution: Round numbers can change between years:Issue: Missing session timing data
Problem:get_session_date() raises ValueError.
Solution: Not all events have complete timing data:
Related Pages
Core API
Load and work with session data (Session, Laps, Telemetry)
Schedule Validation
Schedule data validation and schema
HTTP & Networking
CDN fetching, caching, and network configuration
Data Flow
Understand how event data flows through tif1
Caching Strategy
Learn about tif1’s caching mechanisms
CLI Usage
Use tif1’s command-line interface for event discovery
API Reference Summary
Functions
Classes
Key Properties
Event properties:year: Season year (int)EventName: Official event name (str)Location: Circuit name (str)Country: Country (str)RoundNumber: Championship round (int)EventDate: Event date (Timestamp)EventFormat: “conventional”, “sprint”, or “testing” (str)
year: Season year (int | None)- All pandas DataFrame properties and methods
Version History
Changes in tif1 2.0
- Added
EventScheduleclass with enhanced lookup methods - Improved fuzzy matching algorithm for event names
- Added
include_testingparameter toget_event_schedule() - Enhanced session timing data with timezone support
- Added vendored schedule data for recent seasons
- Improved error messages and exception handling
Deprecated Features
None. The events API is stable and fully supported.Need help? If you encounter issues with the events API, check the Troubleshooting section above or open an issue on GitHub with details about your use case.