In [2]:
import nflgame
weeks = []
for week in range(1, 6):
game = nflgame.games(2013, week=week)
weeks.append(nflgame.combine_game_stats(game))
In [3]:
labels = range(1, 6)
td_counts = []
for week in weeks:
d = {}
for p in week.sort('tds'):
if p.name in ['T.Brady', 'W.Welker']:
d[p.name] = p.tds
if d:
td_counts.append(d)
td_counts
Out[3]:
In [4]:
import pandas
df = pandas.DataFrame(td_counts, index=labels)
df
Out[4]:
In [5]:
import vincent
vincent.core.initialize_notebook()
line = vincent.GroupedBar(df)
line.width = 600
line.height = 400
line.axis_titles(x='Week', y='Touchdowns')
line.legend('Player')
line.display()