Babe Ruth Home Runs

Source Notebook

Details about every regular-season major league home run hit by Babe Ruth

Details

The data is imported from baseball-reference.com and formatted for computation.
The default content is a Dataset contaning the following properties for each home run include:
"BattingOrderPosition"Ruth's batting order position
"BoxScoreURL"baseball-reference url of game box score
"CareerCount"count of Ruth's home runs in his career
"Date"date of the game
"Description"brief description including direction and baserunners
"FieldingPosition"Ruth's fielding position
"GameCount"count of Ruth's home runs in the game
"Inning"inning where "t" and "b" indicate top and bottom
"Location"whether Ruth was home or away
"Notes"notes including walk-off and inside-the-park
"OnBase"position of runners on base
"Opponent"opposing team identifier
"Pitcher"name of opposing pitcher
"PitcherURL"baseball-reference url for the opposing pitcher
"RBIs"number of RBIs for Ruth
"Score"game score preceding the home run
"Team"Ruth's team
"WinExpectency"win expectency of Ruth's team following the home run
"WinProbAdded"win probability added by the home run
"YearCount"count of Ruth's home runs in the season
Additional content elements include:
"Biography"wikipedia article about Ruth
"Image"a photo of Ruth
"Timeline"a TimelinePlot of Ruth's home runs
Babe Ruth held the career home run record from 1921 until 1974 when Hank Aaron hit his 715th home run.
The record keeping from this time period is not perfectly complete. Some fields, like "OnBase" have Missing values where the correct value is unknown.

Examples

Get a Dataset containing rows for each home run:

In[1]:=
ResourceData[\!\(\*
TagBox["\"\<Babe Ruth Home Runs\>\"",
#& ,
BoxID -> "ResourceTag-Babe Ruth Home Runs-Input",
AutoDelete->True]\)]
Out[1]=

Find the most common opponents:

In[2]:=
ResourceData[\!\(\*
TagBox["\"\<Babe Ruth Home Runs\>\"",
#& ,
BoxID -> "ResourceTag-Babe Ruth Home Runs-Input",
AutoDelete->True]\)][Counts, "Opponent"]
Out[2]=

Scope & Additional Elements (3) 

Get a timeline plot of home runs:

In[3]:=
ResourceData[\!\(\*
TagBox["\"\<Babe Ruth Home Runs\>\"",
#& ,
BoxID -> "ResourceTag-Babe Ruth Home Runs-Input",
AutoDelete->True]\), "Timeline"]
Out[3]=

Retrieve an image of the Bambino whacking a famous dinger:

In[4]:=
ResourceData[\!\(\*
TagBox["\"\<Babe Ruth Home Runs\>\"",
#& ,
BoxID -> "ResourceTag-Babe Ruth Home Runs-Input",
AutoDelete->True]\), "Image"]
Out[4]=

Get a random row:

In[5]:=
randomrow = Normal@RandomChoice@ResourceData[\!\(\*
TagBox["\"\<Babe Ruth Home Runs\>\"",
#& ,
BoxID -> "ResourceTag-Babe Ruth Home Runs-Input",
AutoDelete->True]\)]
Out[5]=

See the pattern of the data:

In[6]:=
ResourceFunction["GetKeyValuePattern"][DeleteMissing@randomrow]
Out[6]=

Visualizations (2) 

Plot home runs by inning, noting that Ruth typically hit third in the lineup skewing his appearances toward the first and away from the second inning:

In[7]:=
Histogram[ResourceData[\!\(\*
TagBox["\"\<Babe Ruth Home Runs\>\"",
#& ,
BoxID -> "ResourceTag-Babe Ruth Home Runs-Input",
AutoDelete->True]\)][
  All/*(ToExpression[StringReplace[#, "t" | "b" -> ""]] &), "Inning"],
  PlotLabel -> "Babe Ruth Home Runs by Inning"]
Out[7]=

Ruth hit more home runs against the Detroit Tigers than any other team:

In[8]:=
BarChart[ReverseSort@ResourceData[\!\(\*
TagBox["\"\<Babe Ruth Home Runs\>\"",
#& ,
BoxID -> "ResourceTag-Babe Ruth Home Runs-Input",
AutoDelete->True]\)][Counts, "Opponent"], ChartLabels -> Automatic]
Out[8]=

Analysis (3) 

The total number of home runs. For decades this was considered an unbreakable record:

In[9]:=
Length[ResourceData[\!\(\*
TagBox["\"\<Babe Ruth Home Runs\>\"",
#& ,
BoxID -> "ResourceTag-Babe Ruth Home Runs-Input",
AutoDelete->True]\)]]
Out[9]=

Find his "walk off" home runs by finding HRs hit in the bottom of the ninth inning (or later) with the score difference less than the number of RBIs:

In[10]:=
walkoffs = ResourceData[\!\(\*
TagBox["\"\<Babe Ruth Home Runs\>\"",
#& ,
BoxID -> "ResourceTag-Babe Ruth Home Runs-Input",
AutoDelete->True]\)][
  Select[StringMatchQ[#Inning, "b " ~~ ("9" | (DigitCharacter ~~ DigitCharacter))] && StringQ[#Score] && StringMatchQ[#Score, "tied*" | ("behind " ~~ sc1__ ~~ "-" ~~ sc2__ /; ToExpression[sc1] + #RBIs > ToExpression[sc2])] &]]
Out[10]=

Compare it with the baseball-reference notes:

In[11]:=
Normal[walkoffs] === Normal[ResourceData[\!\(\*
TagBox["\"\<Babe Ruth Home Runs\>\"",
#& ,
BoxID -> "ResourceTag-Babe Ruth Home Runs-Input",
AutoDelete->True]\)][Select[#Notes === "Walk-Off" &]]]
Out[11]=

Find the most common values for several properties:

In[12]:=
AssociationMap[Normal[ResourceData[\!\(\*
TagBox["\"\<Babe Ruth Home Runs\>\"",
#& ,
BoxID -> "ResourceTag-Babe Ruth Home Runs-Input",
AutoDelete->True]\)][
    Counts/*TakeLargest[UpTo[5]], #]] &, {"GameCount", "Date", "Team",
   "Opponent", "Pitcher", "Location", "Score", "RBIs", "OnBase", "BattingOrderPosition", "FieldingPosition"}]
Out[12]=

Bob, "Babe Ruth Home Runs" from the Wolfram Data Repository (2021)  

Data Resource History

Source Metadata

Data Downloads

Publisher Information