01 · Data Pipeline
First notebook establishes the data foundation for the study by importing raw Statcast event-level
records, standardizing field names, and aligning pitch, swing, and ballpark metadata into a single
analytical structure. Raw pulls were performed with the Python package pybaseball
(using the Statcast endpoint) to retrieve all plate-level events across the 2023–2025 seasons; the
goal was to make sure each observation is consistently tied to season, stadium, batter, pitcher,
pitch type, and swing outcome before any interpretation is attempted.
Data filtered strategically, isolating true swing events and produce a clean, analysis-ready sample. The pipeline selects Statcast rows that represent swings (non-null pitch classification and descriptions consistent with swings or contact), limits the set to regular-season games and the 29 stadiums with valid park identifiers, and removes duplicate or incomplete records (for example, missing pitch type, missing launch metrics when contact-quality analysis requires them, or invalid park metadata). When contact-quality metrics were needed we additionally required exit velocity and launch angle to be present. These filters preserve the "juicy" observations while avoiding noisy or unusable rows that would bias park-level comparisons.
For downstream work, every cleaned swing-level table was exported to CSV —
per-season CSVs plus a consolidated master CSV — so the same exact sample can be reloaded without
repeating the network pulls. The pipeline also records provenance (query date, pybaseball version,
and filtering steps applied) so results are easily audited and/or re-created later.