Skip to content

Commit

Permalink
8/20/2023 - Updated Repo, made bug fixes.
Browse files Browse the repository at this point in the history
- Updated the YAML scripts that update player game stats to not run when there is a git push or pull to this repo.
- Added explanations for PBP and teams columns, as well as finishing up the explanation of player season pitching stats data columns.
- Fixed a bug in `get_milb_pbp.py` that would result in pitch types not being sourced correctly from the JSON data response.
- Updated the `README.md` file to reflect new additions to the repo.
  • Loading branch information
armstjc committed Aug 20, 2023
1 parent 3309f48 commit 67d1639
Show file tree
Hide file tree
Showing 15 changed files with 392 additions and 153 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/update_milb_player_game_stats_a+.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ name: Update MiLB Player Game Stats - A+
on:
schedule:
- cron: "30 7 * 3-10 *"
push:
branches: [main]
pull_request:
branches: [main]
# push:
# branches: [main]
# pull_request:
# branches: [main]

jobs:
build:
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/update_milb_player_game_stats_a.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ name: Update MiLB Player Game Stats - A
on:
schedule:
- cron: "30 8 * 3-10 *"
push:
branches: [main]
pull_request:
branches: [main]
# push:
# branches: [main]
# pull_request:
# branches: [main]

jobs:
build:
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/update_milb_player_game_stats_aa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ name: Update MiLB Player Game Stats - AA
on:
schedule:
- cron: "30 6 * 3-10 *"
push:
branches: [main]
pull_request:
branches: [main]
# push:
# branches: [main]
# pull_request:
# branches: [main]

jobs:
build:
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/update_milb_player_game_stats_aaa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ name: Update MiLB Player Game Stats - AAA
on:
schedule:
- cron: "30 5 * 3-10 *"
push:
branches: [main]
pull_request:
branches: [main]
# push:
# branches: [main]
# pull_request:
# branches: [main]

jobs:
build:
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/update_milb_player_game_stats_rk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ name: Update MiLB Player Game Stats - Rookie Ball
on:
schedule:
- cron: "30 9 * 5-10 *"
push:
branches: [main]
pull_request:
branches: [main]
# push:
# branches: [main]
# pull_request:
# branches: [main]

jobs:
build:
Expand Down
39 changes: 22 additions & 17 deletions README.md

Large diffs are not rendered by default.

Binary file added column_descriptions/hitter_zones.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
84 changes: 84 additions & 0 deletions column_descriptions/pbp.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
Column Name,Full Column Name,Data Type,Description,Example
play_start_datetime,Play Start Date and time,`datetime`,The exact date and time of the start of this specific play.,`2021-10-01 22:07:33`
play_end_datetime,Play End Date and time,`datetime`,The exact date and time of the end of this specific play.,`2021-10-01 22:07:56.000`
pitch_type,Pitch Type,`str`,The acronym for the pitch thrown by the pitcher in this play.,"""CH"" (Changeup), ""CS"" (Slow Curve), ""CU"" (Curveball), ""FC"" (Cutter), ""FF"" (4-seam fastball), ""FS"" (Splitter), ""FT"" (2-seam fastball), ""KC"" (Knuckle curve), ""KN"" (Knuckle ball), ""SI"" (Sinker), ""SL"" (Slider), ""ST"" (Sweeper), ""SV"" (Slurve)"
pitch_name,Pitch Name,`str`,The name of the pitch thrown by the pitcher in this play.,"""Two-Seam Fastball"", ""Slider"", ""Slow Curve"""
game_date,Game Date,`date`,"The start date of this game. If this play happens after midnight, it will be a differient date compared to `play_start_datetime` and `play_end_datetime`.","""2019-03-23"""
release_speed,Pitch Release Speed,`decimal`,"The release speed of the pitch. Pitch velocities from 2008-16 are via Pitch F/X, and adjusted to roughly out-of-hand release point. All velocities from 2017 and beyond are Statcast, which are reported out-of-hand.","""90"", ""88.6"", "
release_pos_x,Release Position X-axis,`decimal`,The Horizontal Release Position of the ball measured in feet from the catcher's perspective.,
release_pos_y,Release Position Y-axis,`decimal`,The Y-axis Release location of the ball measured in feet from the catcher's perspective.,
release_pos_z,Release Position Z-axis,`decimal`,The Vertical Release Position of the ball measured in feet from the catcher's perspective.,
player_name,Player Name,`str`,"For this play, this is the key player's name.",
batter,Batter ID,`int`,The player ID for the batter on this play.,
pitcher,Pitcher ID,`int`,The player ID for the pitcher on this play.,
description,Play Description,`str`,"The description of this play, or how this at bat ended.",
spin_dir,Pitch Spin Direction,`int`,"The 0-360 degree spin of the pitch in this play. For a more detailed explanation, [consult this article by Robert Frey on how spin direction works, and how it influences pitches](https://rfrey22.medium.com/what-spin-direction-tells-us-from-mlb-data-3632c772c22e).",
zone,Strikeout Zone,`int`,"The zone (1-9, 11-14) of where the ball crosses the plate. Zones 1-9 are within the strike zone, while zones 11-14 are outside the strikezone. [Click Here](https://github.com/armstjc/milb-data-repository/blob/main/column_descriptions/hitter_zones.png) for a visual guide on strikeout zones.",
des,Sequence Description,`str`,The description of how this at bat ended.,
game_type,Game Type,`str`,The MLB key on what type of game this play happened in.,"E = Exhibition, S = Spring Training, R = Regular Season, F = Wild Card, D = Divisional Series, L = League Championship Series, W = World Series"
stand,Batter Side,`str`,The side of the plate batter is standing.,"R = Right, L = Left"
p_throws,Pitching Throwing Hand,`str`,The hand the pitcher threw with on this play.,"R = Right, L = Left"
home_team,Home Team Abbreviation,`str`,The abbreviation of the home team in this play.,
away_team,Away Team Abbreviation,`str`,The abbreviation of the away team in this play.,
type,Play Type,`str`,"The short hand abbreviation of this play, and what it resulted in.","B = ball, S = strike, X = in play."
hit_location,Hit Location,`int`,"The player number (1-9) of who first touched a ball in play, and/or which part of the field a ball in play landed. ",
bb_type,Batted Ball Type,`str`,"The batted ball type for this play, if the batter put the ball in play.","""ground_ball"", ""line_drive"", ""fly_ball"", ""popup"""
balls,Balls,`int`,"The number of balls called by the end of this play in this at bat. If this is the first pitch in this at bat, and it is rulled a ball, this column will indicate ""1"" in the `balls` column, and ""0"" in the `strikes` column.",
strikes,Strikes,`int`,"The number of strikes accured by the end of this play in this at bat. If this is the first pitch in this at bat, and it is rulled a called strike, this column will indicate ""0"" in the `balls` column, and ""1"" in the `strikes` column.",
pfx_x,Pitch F/X - X,`decimal`,"The horizontal (left/right) movement for this pitch, before the pitch makes it to the catcher, in feet, from the prospective of the catcher.",
pfx_z,Pitch F/X - Z,`decimal`,"The vertical (up/down) movement for this pitch, before the pitch makes it to the catcher, in feet, from the prospective of the catcher.",
plate_x,Plate - X,`decimal`,"The horizontal (left/right) location of this pitch when it crosses home plate, in feet, from the catcher's perspective.",
plate_z,Plate - Z,`decimal`,"The vertical (up/down) location of this pitch when it crosses home plate, in feet, from the catcher's perspective.",
on_3b,Runner on 3rd Base,`int`,"If there is a runner on 3rd base at the start of the play, this column will have the player ID for the runner on 3rd base.",
on_2b,Runner on 2nd Base,`int`,"If there is a runner on 2nd base at the start of the play, this column will have the player ID for the runner on 2nd base.",
on_1b,Runner on 1st Base,`int`,"If there is a runner on 1st base at the start of the play, this column will have the player ID for the runner on 1st base.",
outs_when_up,Outs When Up at bat,`int`,The number of outs at the start of this at bat.,
inning,Inning,`int`,The inning this play takes place in.,
inning_topbot,Inning Top/Bottom,`str`,The indicator for which part of the inning this play takes place in.,"""Top"", ""Bot"""
hc_x,Hit Coordinate - X,`decimal`,The X axis of where a ball hit into play landed.,
hc_y,Hit Coordinate - Y,`decimal`,The Y axis of where a ball hit into play landed.,
vx0,Pitch Velocity - X,`decimal`,"The velocity of the pitch, in feet per second (ft/s), while in the X axis, calculated while the ball is 50 ft. from home plate (y=50 ft.).",
vy0,Pitch Velocity - Y,`decimal`,"The velocity of the pitch, in feet per second (ft/s), while in the Y axis, calculated while the ball is 50 ft. from home plate (y=50 ft.).",
vz0,Pitch Velocity - Z,`decimal`,"The velocity of the pitch, in feet per second (ft/s), while in the Z axis, calculated while the ball is 50 ft. from home plate (y=50 ft.).",
ax,Pitch Accelaration - X,`decimal`,"The accelaration of the pitch, in feet per second (ft/s), while in the X axis, calculated while the ball is 50 ft. from home plate (y=50 ft.).",
ay,Pitch Accelaration - Y,`decimal`,"The accelaration of the pitch, in feet per second (ft/s), while in the Y axis, calculated while the ball is 50 ft. from home plate (y=50 ft.).",
az,Pitch Accelaration - Z,`decimal`,"The accelaration of the pitch, in feet per second (ft/s), while in the Z axis, calculated while the ball is 50 ft. from home plate (y=50 ft.).",
sz_top,Strike Zone - Top,`decimal`,The top of the batter's strike zone set by the operator when the ball is halfway to the plate.,
sz_bot,Strike Zone - Bottom,`decimal`,The bottom of the batter's strike zone set by the operator when the ball is halfway to the plate.,
hit_distance_sc,Hit Distance,`int`,The projected hit distance of a ball hit into play.,
launch_speed,Launch Speed,`decimal`,"The exit velocity of a ball hit into play, derived by tracking data.",
launch_angle,Launch Angle,`int`,"The launch angle of a ball hit into play, derived by tracking data.",
release_spin_rate,Release Spin Rate,`int`,"The spin rate of the pitch thrown by the pitcher on this play. Typically, higher is better.",
release_extension,Release Extension,`decimal`,"The distance in feet between where the ball is released, and the rubber on the piching mound is, when a pitch is thrown. `release_extension` being a positive number indicates that the ball was released X feet from the rubber to home plate, while a negative `release_extension` (very improbable, but not impossible) means the ball was released behind the rubber on the pitching mound.",
game_pk,Game ID/Primary Key,`int`,"The game, and by extension Game ID this play corresponds to.",
pitcher_1,Fielder 1 - Pitcher,`int`,"For defensive fielding purposes this is the player ID for the pitcher, or the ""1"" player.",
fielder_2,Fielder 2 - Catcher (C),`int`,"For defensive fielding purposes this is the player ID for the catcher, or the ""2"" player.",
fielder_3,Fielder 3 - First Baseman (1B),`int`,"For defensive fielding purposes this is the player ID for the first baseman, or the ""3"" player.",
fielder_4,Fielder 4 - Second Baseman (2B),`int`,"For defensive fielding purposes this is the player ID for the second baseman, or the ""4"" player.",
fielder_5,Fielder 5 - Third Baseman (3B),`int`,"For defensive fielding purposes this is the player ID for the third baseman, or the ""5"" player.",
fielder_6,Fielder 6 - Shortstop (SS),`int`,"For defensive fielding purposes this is the player ID for the shortstop, or the ""6"" player.",
fielder_7,Fielder 7 - Left Fielder (LF),`int`,"For defensive fielding purposes this is the player ID for the left fielder, or the ""7"" player.",
fielder_8,Fielder 8 - Center Fielder (CF),`int`,"For defensive fielding purposes this is the player ID for the center fielder, or the ""8"" player.",
fielder_9,Fielder 9 - Right Fielder (RF),`int`,"For defensive fielding purposes this is the player ID for the right fielder, or the ""8"" player.",
at_bat_number,At Bat Number,`int`,This indicates the Xth at bat this play takes part in.,
pitch_number,At Bat Pitch Number,`int`,"This indicates the Xth pitch this play takes part in, within an at bat. This is not a cumulative count of every pitch thrown by the pitcher in the entire game.",
home_score,Home Team Score,`int`,The score of the home team at the start of this play.,
away_score,Away Team Score,`int`,The score of the away team at the start of this play.,
bat_score,Batting Team Score,`int`,The score of the batting team at the start of this play.,
fld_score,Fielding Team Score,`int`,The score of the fielding/pitching team at the start of this play.,
post_away_score,Post Home Team Score,`int`,The score of the home team at the end of this play.,
post_home_score,Post Away Team Score,`int`,The score of the away team at the end of this play.,
post_bat_score,Post Batting Team Score,`int`,The score of the batting team at the end of this play.,
post_fld_score,Post Fielding Team Score,`int`,The score of the fielding/pitching team at the end of this play.,
spin_axis,Pitch Spin Axis,`int`,"The Spin Axis in the 2D X-Z plane in degrees from 0 to 360, such that 180 represents a pure backspin fastball and 0 degrees represents a pure topspin (12-6) curveball",
game_month,Game Month,`int`,The month (1-12) this game took place in.,
game_day,Game Day,`int`,The day (1-31) this game took place in.,
game_year,Game Year,`int`,The calender year this game took place in.,
leauge_id,League ID,`int`,The ID for which MiLB league this game was played under.,"""109"" (Texas League, Double-A), ""221"" (International League, Triple-A), ""560"" (Arizona Complex League, Rookie)"
leauge_name,League Name,`str`,The name for which MiLB league this game was played under.,"""Texas League"" (Double-A), ""International League"" (Triple-A), ""Arizona Complex League"" (Rookie)"
league_level_id,League Level ID,`int`,This is the ID for the MiLB level this game was played at.,"""12"" (Tulsa Drillers, Double-A), ""11"" (Columbus Clippers, Triple-A) , ""16"" (ACL Giants Orange, Arizona Complex League)"
league_level_name,League Level Name,`str`,This is the name for the MiLB level this game was played at.,"""Double-A"" (Tulsa Drillers, Double-A), ""Triple-A"" (Columbus Clippers, Triple-A) , ""Rookie"" (ACL Giants Orange, Arizona Complex League)"
away_team_org_id,Away Team Parent Organization ID,`int`,"If the away MiLB team has a parent MLB organization, this is the MLB team ID of that parent organization.","""119"" (MLB team: Los Angeles Dodgers; MiLB team: Tulsa Drillers, Double-A), ""114"" (MLB team: Cleveland Guardians, MiLB team: Columbus Clippers, Triple-A) , ""137"" (MLB team: San Francisco Giants, MiLB team: ACL Giants Orange, Arizona Complex League)"
away_team_org_name,Away Team Parent Organization Name,`str`,"If the away MiLB team has a parent MLB organization, this is the MLB team name of that parent organization.","""Tulsa"" (Tulsa Drillers, Double-A), ""Columbus"" (Columbus Clippers, Triple-A) , ""ACL Giants Orange"" (ACL Giants Orange, Arizona Complex League)"
home_team_org_id,Home Team Parent Organization ID,`int`,"If the home MiLB team has a parent MLB organization, this is the MLB team ID of that parent organization.","""119"" (MLB team: Los Angeles Dodgers; MiLB team: Tulsa Drillers, Double-A), ""114"" (MLB team: Cleveland Guardians, MiLB team: Columbus Clippers, Triple-A) , ""137"" (MLB team: San Francisco Giants, MiLB team: ACL Giants Orange, Arizona Complex League)"
home_team_org_name,Home Team Parent Organization Name,`str`,"If the home MiLB team has a parent MLB organization, this is the MLB team name of that parent organization.","""Tulsa"" (Tulsa Drillers, Double-A), ""Columbus"" (Columbus Clippers, Triple-A) , ""ACL Giants Orange"" (ACL Giants Orange, Arizona Complex League)"
Loading

0 comments on commit 67d1639

Please sign in to comment.