During the 2021 season, the Chicago White Sox and Dunkin Donuts collaborated for a promo on the MLB Ballpark App.
The user selected either the 4th, 5th or 6th inning for home games the entire year, if the Sox scored a run in that inning, you would win a free coffee.
First, import the statsapi package from https://github.com/toddrob99/MLB-StatsAPI/wiki
Then, get all White Sox home games from the 2021 season and keep track of all scoring plays per home game
Next, create a function to check which each scoring play, by the inning
Lastly, loop through each game and keep track of how many times the Sox scored at least one run in that inning
The results:The White Sox scored in the 4th inning 35% of the time
The White Sox scored in the 5th inning 33% of the time
The White Sox scored in the 6th inning 34% of the time