In [1]:
from pybaseball import schedule_and_record
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
In [2]:
yankees = schedule_and_record(1927, 'NYY')
reds = schedule_and_record(1976, 'CIN')
mariners = schedule_and_record(2001, 'SEA')
In [3]:
mariners.describe()
Out[3]:
In [4]:
reds.describe()
Out[4]:
In [5]:
yankees.describe()
Out[5]:
In [6]:
# create a numeric indicator of a win and take cumulative sum of wins-to-date at each point in the season
mariners['win-count'] = np.where(mariners['W/L']=='W', 1, 0).cumsum()
yankees['win-count'] = np.where(yankees['W/L']=='W', 1, 0).cumsum()
reds['win-count'] = np.where(reds['W/L']=='W', 1, 0).cumsum()
In [7]:
plt.plot(mariners['win-count'],label=" '01 Mariners")
plt.plot(yankees['win-count'],label=" '27 Yankees")
plt.plot(reds['win-count'],label=" '76 Reds")
plt.legend(loc=4)
plt.xlabel('Games into Season')
plt.ylabel('Win Count')
plt.title('Record Throughout Season');
Who had the largest win margins? The plot below shows cumulative run differential throughout the season. The Yankees are the clear winners of this one, which is saying a lot considering they are being compared against two of the best teams of all time! Point Murderers Row.
In [8]:
mariners['scorediff'] = (mariners['R'] - mariners['RA']).cumsum()
yankees['scorediff'] = (yankees['R'] - yankees['RA']).cumsum()
reds['scorediff'] = (reds['R'] - reds['RA']).cumsum()
In [9]:
plt.plot(mariners['scorediff'],label=" '01 Mariners")
plt.plot(yankees['scorediff'],label=" '27 Yankees")
plt.plot(reds['scorediff'],label=" '76 Reds")
plt.legend(loc=4)
plt.xlabel('Games into Season')
plt.ylabel('Runs Scored - Runs Against')
plt.title('Cumulative Run Differential');
While all three legendary seasons are memorable, this brief analysis points toward the 1927 Yankees as being the best of the three.