Data Models¶
Classes
|
Represents a Formula 1 season, containing methods to load and manage the season's meetings and sessions. |
|
Represents a meeting in a specific season with relevant details and associated sessions. |
|
Represents a Formula 1 session, containing methods to retrieve live timing data and process it. |
|
Represents a Formula 1 circuit with its characteristics and metadata. |
|
Represents a Formula 1 driver with their associated information. |
Season¶
The Season model is the top-level container for Formula 1 data. It manages all meetings and sessions for a specific year.
Key Attributes:
year
: The F1 season yearmeetings
: List of Meeting objectsmeetings_json
: Raw meeting dataseason_table
: Pandas DataFrame with season datameetings_table
: Aggregated meetings data
Example Usage:
import livef1
# Get a season
season = livef1.get_season(2024)
# Access meetings
print(season.meetings_table) # View all meetings
print(season.meetings) # Access Meeting objects
# Get specific meeting
monaco_gp = [m for m in season.meetings if m.location == "Monaco"][0]
Meeting¶
The Meeting model represents a specific Grand Prix event within a season. It manages session data and meeting metadata.
Key Attributes:
season
: Reference to parent Season objectcode
: Meeting code (e.g., “MON”)key
: Unique identifierlocation
: Circuit locationname
: Grand Prix namesessions
: List of Session objectssessions_table
: DataFrame of session data
Example Usage:
# Get specific meeting
meeting = livef1.get_meeting(
season=2024,
meeting_identifier="Monaco"
)
# Access sessions
print(meeting.sessions_table) # View all sessions
# Get specific session
race = [s for s in meeting.sessions if s.type == "Race"][0]
Session¶
The Session model represents individual F1 sessions (Practice, Qualifying, Race) and implements the medallion architecture for data processing.
Key Attributes:
meeting
: Reference to parent Meeting objecttype
: Session type (e.g., “Race”, “Practice 1”)name
: Session namekey
: Unique identifierstartdate
: Session start timeenddate
: Session end timedata_lake
: DataLake object for data storagetopic_names_info
: Available data topics
Data Access Methods:
get_data()
: Retrieve raw datagenerate()
: Create processed tableslaps
: Access lap datacarTelemetry
: Access telemetry data
Example Usage:
# Get specific session
session = livef1.get_session(
season=2024,
meeting_identifier="Monaco",
session_identifier="Race"
)
# Load raw data
telemetry = session.get_data("CarData.z")
# Generate processed tables
session.generate(silver=True)
# Access processed data
laps = session.laps
telemetry = session.carTelemetry
Data Flow¶
The models work together in a hierarchical structure:
Season
├── Meeting 1
│ ├── Practice 1
│ ├── Practice 2
│ ├── Practice 3
│ ├── Qualifying
│ └── Race
├── Meeting 2
│ └── ...
└── Meeting N
└── ...
Each level provides specific functionality:
Season Level
Season-wide data access
Meeting management
Meeting Level
Session management
Meeting-specific data
Circuit information
Session Level
Raw data access
Data processing
DataLake architecture implementation
Best Practices¶
Data Access
Use high-level functions (
get_season()
,get_meeting()
,get_session()
)Access objects through their parent when possible
Use data frames for bulk data analysis
Data Processing
Generate silver tables before accessing processed data
Use parallel processing for multiple data topics
Cache frequently accessed data
Memory Management
Load data only when needed
Use data lake for persistent storage
Clear unused data from memory
See also
For more details on data processing, see Data Lake Architecture
For API documentation, see API Reference