Skip to content

Instantly share code, notes, and snippets.

@ochawkeye
Last active October 27, 2015 23:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ochawkeye/360ca56762e2f229626f to your computer and use it in GitHub Desktop.
Save ochawkeye/360ca56762e2f229626f to your computer and use it in GitHub Desktop.
import nfldb
from collections import defaultdict
db = nfldb.connect()
q = nfldb.Query(db)
q.game(season_year=2015, week=7)
results = {team[0]: {} for team in nfldb.team.teams}
for d in q.as_drives():
if d.result not in results[d.pos_team]:
results[d.pos_team][d.result] = 1
else:
results[d.pos_team][d.result] += 1
for team in results:
print team, results[team]
@ochawkeye
Copy link
Author

MIN {'Field Goal': 5, 'Punt': 2, 'Safety': 1, 'Fumble': 1, 'Touchdown': 2, 'End of Game': 1}
MIA {'End of Half': 1, 'Field Goal': 1, 'Punt': 5, 'Fumble': 1, 'Touchdown': 5, 'End of Game': 1}
CAR {'Touchdown': 3, 'End of Half': 1, 'Punt': 4, 'Interception': 3, 'Field Goal': 2}
ATL {'End of Half': 1, 'Interception': 2, 'End of Game': 1, 'Punt': 4, 'Touchdown': 1, 'Missed FG': 1, 'Field Goal': 1, 'Downs': 1}
DET {'Touchdown': 2, 'Downs': 2, 'Punt': 6, 'Field Goal': 1}
CIN {}
NYJ {'Touchdown': 2, 'Punt': 4, 'Field Goal': 3, 'Fumble': 1, 'End of Game': 1}
DEN {}
BAL {'Touchdown': 2, 'Punt': 6, 'Interception': 1, 'Field Goal': 1}
NYG {'Touchdown': 2, 'End of Half': 1, 'Punt': 5, 'Field Goal': 2, 'End of Game': 1}
OAK {'Touchdown': 4, 'Punt': 4, 'Field Goal': 3, 'End of Game': 1}
TEN {'Touchdown': 1, 'Downs': 1, 'Punt': 7, 'Interception': 2}
NO {'Touchdown': 4, 'End of Half': 1, 'Punt': 10, 'Interception': 1, 'End of Game': 1}
DAL {'Touchdown': 2, 'Downs': 1, 'Punt': 2, 'Interception': 3, 'Field Goal': 2}
NE {'Touchdown': 3, 'End of Half': 1, 'Punt': 3, 'Field Goal': 3}
SEA {'Touchdown': 2, 'Punt': 4, 'Interception': 2, 'Field Goal': 2, 'End of Game': 1}
CLE {'Downs': 1, 'Punt': 5, 'Fumble': 4, 'End of Half': 1, 'Field Goal': 2}
BUF {'Downs': 1, 'Interception': 2, 'Field Goal': 3, 'Punt': 3, 'Fumble': 2, 'Touchdown': 2}
STL {'Field Goal': 1, 'Punt': 5, 'Fumble': 1, 'Touchdown': 2, 'Missed FG': 2, 'End of Game': 1}
CHI {}
TB {'Touchdown': 2, 'End of Half': 1, 'Punt': 2, 'Fumble': 1, 'Field Goal': 3}
HOU {'Touchdown': 4, 'Downs': 1, 'Punt': 8, 'Interception': 1}
GB {}
UNK {}
WAS {'Touchdown': 4, 'Punt': 4, 'Field Goal': 1, 'Fumble': 1, 'End of Game': 1}
JAC {'Downs': 1, 'Interception': 1, 'End of Game': 1, 'Punt': 6, 'Touchdown': 3, 'End of Half': 1}
KC {'Touchdown': 2, 'Missed FG': 1, 'Punt': 3, 'Field Goal': 3, 'End of Game': 1}
PHI {'Downs': 1, 'Interception': 1, 'Field Goal': 3, 'Punt': 5, 'Touchdown': 1, 'Missed FG': 1, 'End of Game': 1}
PIT {'End of Half': 1, 'Interception': 2, 'Field Goal': 2, 'Punt': 2, 'Fumble': 1, 'Touchdown': 1, 'Downs': 1}
IND {'Touchdown': 3, 'Punt': 10, 'Interception': 2, 'Fumble': 1}
ARI {'Blocked Punt': 1, 'Field Goal': 2, 'Punt': 3, 'Touchdown': 3, 'Missed FG': 1, 'End of Game': 1}
SF {'End of Half': 1, 'Punt': 9, 'Field Goal': 1}
SD {'Touchdown': 3, 'Punt': 5, 'Interception': 2, 'Field Goal': 2}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment