1 of 23

Lahman Baseball Dataset Analysis

Patrick Samuels and [team partner]

2 of 23

Topic and Motivation

Topic:

  • Analyze baseball All-Star data

Motivation:

  • Project coinciding with World Series
  • Find interesting insights using public datasets

3 of 23

Dataset Description

Data Source:

  • CSV file from Lahman Baseball Database
  • Built from AllstarFull.csv

Big Data:

  • Volume
  • Variety

Base Dataset Columns:

  • Player ID
  • Year ID
  • Game number
  • Game ID
  • Team ID
  • League ID
  • Game played
  • Starting position

Formats:

  • Text (Names)
  • Numerical (Batting avg.)
  • Temporal (Game dates)
  • Categorical (League)
  • Boolean (Starting?)

4 of 23

Data Architecture and Cleaning

  • Cleaned AllstarFull.csv using Python
    • Remove invalid values
    • Add player positions instead of number (ex. 1 = Pitcher)

# "Bench" for empty starting positions

df['startingPos'] = df['startingPos'].fillna('Bench')

​

# Convert numeric-like positions to integers, keep "Bench" as text

df['startingPos'] = df['startingPos'].apply(lambda x: int(x) if str(x).isdigit() else x)

​

5 of 23

Data Architecture and Cleaning

Added Dataset Columns from related datasets:

  • Position name
  • Was a starting player
  • Added player first and last name

6 of 23

Data Processing and Transformation

Utilized Python to merge the All Star dataset with other datasets (Batting.csv + Pitching.csv) to allow for more insightful analysis

  • Stats: ERA, H, HR
  • Personal Info: Birth country, Height, First and last name

Created:

  • allstar_pitching_people.csv
    • 59 fields 1942 rows
  • allstar_batting_people.csv
    • 51 fields 5787 rows

​

7 of 23

8 of 23

Visualizations

Used Tableau to import database, analyze data, and create visualizations and dashboards

Interests:

  • Pitching
    • The evolution limiting pitcher innings and its effects
    • Correlation of strikeouts and earned run average
    • The effect of certain events over the existence of MLB
  • Batting
    • Prevalence of double plays
    • Intentional walks
    • Hits, home runs, and runs batted in over the years

9 of 23

Dashboards (Pitching Stats)

10 of 23

11 of 23

12 of 23

Dashboards (Batting Stats)

13 of 23

14 of 23

15 of 23

Dashboards (Overview & League Stats)

16 of 23

17 of 23

18 of 23

Key Findings

  • Complete games and innings pitched reduced over the years most likely due to pitches increasing in speed, which takes a harder toll on the pitcher, as well as data analysis that showed pitcher effectiveness reduced third time through the order.
  • Weight of pitchers and hitters has risen more dramatically in recent years compared to height. Most likely due to better training and nutrition, and the steroid era.
  • There is an overall increase in double plays over time, but there is a noticeable spike in the late 1990s and early 2010s. This could be caused by an increase in defensive metrics, analytics, and shifting to combat a batter's strengths.

19 of 23

Key Findings (pt. 2)

  • The top players of all time were
    • #1: Hank Aaron - 17 games played as an all-star with 1,766 hits.
  • 1959 had the most starting All-star players with:
    • 1,959 starting benched players & 18 all-star players starting for all other positions besides right field which had 19.
  • The Hits per year bar chart shows there were very few hits in some years compared to others (2024 vs 1959), sorted by position name. 2017 also had much fewer hits compared to other years.

​

20 of 23

Ethical Considerations and Implications

Data Privacy:

  • No glaring issues
    • Publicly available data

Biases:

  • Missing data predating 1934
  • Introduced stats
    • “Save” stat introduced in 1969
  • Negro league segregation
  • No all star game in:
    • 1945 - World War II
    • 2020 - Covid Pandemic

21 of 23

Ethical Considerations and Implications

Data governance issues:

  • Data pulled from multiple sources
    • Can pull incorrect information
    • Dataset is decommissioned
  • Data availability
    • Some data is only available after the season is over and is not up to date

22 of 23

Future Direction

  • Incorporate more data values: spin rate, exit velocity, defensive metrics, etc.
  • Continued analysis: Stats have shown a general increase overtime (HRs, Steals, Pitch Velocity). It would be interesting to see if these stats plateau due to the human body being pushed to its limits or if players continue to improve
  • Further exploration into player and team performance over time, noting which teams made most appearances by player, what other teams they played on and how those teams performed during years those all-stars had played. Which other all-stars played with those players.

23 of 23

Presentation Recording Link:

https://youtu.be/7WUJdkQILoE