The events module is the gateway to discovering and navigating Formula 1 calendar data. It provides a type-safe API for event schedules, session timings, and metadata across multiple seasons. The module is the foundation for all data discovery operations in
tif1.Overview
The events module provides a complete set of functions and classes. These discover what Formula 1 data is available in the TracingInsights CDN for specific years and events. This module is the primary entry point for event discovery and session navigation intif1. It enables workflows for data analysis, visualization, and automation.
Core Capabilities
Use the events API to:- Query season schedules: Retrieve complete event calendars for any supported F1 season (2018-present). Each calendar carries full metadata, including event names, locations, countries, dates, and formats
- Discover available sessions: Determine which sessions have data available for each event. Sessions include Practice 1-3, Qualifying, Sprint Qualifying, Sprint, and Race
- Access event metadata: Get detailed information about each Grand Prix. The information includes official event names (with sponsors), circuit locations, round numbers, event dates, and weekend formats
- Navigate flexibly: Use fuzzy matching to find events by partial names, abbreviations, circuit names, or round numbers. Exact string matches are not required
- Work with timezone-aware data: Access session start times in both local circuit timezone and UTC. This enables accurate time-based analysis and scheduling
- Handle different event formats: Work with conventional race weekends (3 practice sessions), sprint weekends, and pre-season testing events. Sprint weekend formats vary by year
- Use pandas integration: Work with DataFrame and Series interfaces enhanced with domain-specific methods for F1 data navigation
- Benefit from caching: All schedule data is cached in-memory after the first fetch. Subsequent queries are instant and use no 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 integration with the broader pandas ecosystem.
- Flexible Querying: Multiple lookup methods exist: by round number, by name, or by fuzzy match. Each use case, programmatic or interactive, has a suitable method.
- Type Safety: Full type hints throughout the API enable IDE autocomplete and static type checking with mypy or pyright.
- Graceful Degradation: The module handles missing data, network failures, and edge cases gracefully. It provides 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
tif1. They give instant access without network requests - f1schedule CDN: Historical seasons are fetched from the
theOehrly/f1scheduleGitHub repository 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. This object is a specialized pandas DataFrame subclass with methods for event lookup and filtering. Each row in the DataFrame represents a single Grand Prix event. The row carries 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 (for example, “Belgian Grand Prix”)Location: Circuit or venue name (for example, “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
theOehrly/f1schedulerepository (via jsDelivr). Vendored JSON files in the package cover recent seasons. - Testing Events: By default,
get_events()includes all events including pre-season testing. Useget_event_schedule(year, include_testing=False)to exclude testing events. - Performance: This function is optimized. It typically completes in <10ms for cached data or <200ms for an 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. Use the official event name (for example, “Belgian Grand Prix”). Fuzzy matching is applied internally, so partial names like “Belgian” 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 fuzzy matching to find events even with partial or misspelled names. For example, “Silverstone”, “British”, and “British Grand Prix” 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 does not guarantee all data types (laps, telemetry, etc.) are available for that session.
- Empty Lists: If an event has no sessions (rare edge case), the function returns an empty list. No exception is raised.
get_event
Event object is a pandas Series subclass. It contains all event metadata. It also 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 for precise control or 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 the preferred error handling behavior.
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. For example, a request for round 25 in a season with 22 rounds raises this error.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 the round number is known.
- Reliability: Round numbers are unambiguous and do not require any fuzzy matching or string comparison. This makes the method the most reliable lookup option.
- Caching: Event objects are cached after creation, so repeated calls with the same parameters return instantly.
- Testing Events: Pre-season testing events typically do not 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 the exact official event name is available
- Interactive applications where users type event names
- When accepting partial or abbreviated input
- When flexible input handling is needed
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 Levenshtein distance (edit distance) and token-based matching to find the closest event name. The algorithm tokenizes the search query and the event names. It 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. Each call performs the matching algorithm, but the resulting Event object is reused.
get_event_schedule
EventSchedule object is a specialized pandas DataFrame subclass. It includes all the standard DataFrame functionality plus F1-specific methods for event lookup and filtering. Each row represents a single Grand Prix event with full 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
- Complete 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 (for example, “Belgian Grand Prix”)Location: Circuit or venue name (for example, “Spa-Francorchamps”)OfficialEventName: Full official event title with sponsors (for example, “FORMULA 1 ROLEX BELGIAN GRAND PRIX 2021”)RoundNumber: Championship round number (1-indexed integer)Country: Country where the event takes place (for example, “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 (for example, “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 (recent seasons) or the TracingInsights CDN (historical seasons). The data source is invisible to the caller.
-
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 (for example, “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 fits the 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 (for example, “Belgian Grand Prix”).
str
The event location (for example, “Spa-Francorchamps”).
str
The full official event name (for example, “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 (for example, “conventional”, “sprint”).
str
Session names (for example, “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 (for example, “Qualifying”, “Race”)
- Session abbreviation (for example, “Q”, “R”, “FP1”)
- Session number (for example, 1, 2, 3)
Sessionobject ready to load data
ValueError: If the session identifier is invalid or does not 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 does not 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 do not require fuzzy matching:include_testing=False when appropriate
Exclude testing events when they are not needed. This reduces 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 do not 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? For issues with the events API, check the Troubleshooting section above. To report a problem, open an issue on GitHub with details about the use case.