Skip to content

Instantly share code, notes, and snippets.

@ochawkeye
Created October 27, 2015 22:36
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/bb72b6cb2cd5e14a1a0e to your computer and use it in GitHub Desktop.
Save ochawkeye/bb72b6cb2cd5e14a1a0e to your computer and use it in GitHub Desktop.
import nfldb
db = nfldb.connect()
q = nfldb.Query(db)
q.game(season_year=2015)
interceptions = {team[0]: 0 for team in nfldb.team.teams}
fumble_recoveries = {team[0]: 0 for team in nfldb.team.teams}
turnovers = {team[0]: 0 for team in nfldb.team.teams}
for pp in q.as_play_players():
interceptions[pp.team] += pp.defense_int
fumble_recoveries[pp.team] += pp.defense_frec
turnovers[pp.team] += pp.defense_int + pp.defense_frec
print interceptions
print fumble_recoveries
print turnovers
@ochawkeye
Copy link
Author

{'MIN': 7, 'MIA': 9, 'CAR': 14, 'ATL': 11, 'DET': 4, 'CIN': 8, 'NYJ': 13, 'DEN': 9, 'BAL': 4, 'NYG': 13, 'OAK': 10, 'TEN': 11, 'NO': 8, 'DAL': 4, 'NE': 6, 'SEA': 5, 'CLE': 5, 'BUF': 11, 'STL': 8, 'CHI': 8, 'TB': 9, 'HOU': 8, 'GB': 12, 'UNK': 0, 'WAS': 6, 'JAC': 3, 'KC': 9, 'PHI': 18, 'PIT': 6, 'IND': 10, 'ARI': 16, 'SF': 12, 'SD': 6}
{'MIN': 8, 'MIA': 4, 'CAR': 3, 'ATL': 7, 'DET': 15, 'CIN': 5, 'NYJ': 9, 'DEN': 10, 'BAL': 2, 'NYG': 6, 'OAK': 5, 'TEN': 3, 'NO': 7, 'DAL': 2, 'NE': 3, 'SEA': 7, 'CLE': 7, 'BUF': 3, 'STL': 10, 'CHI': 9, 'TB': 10, 'HOU': 3, 'GB': 3, 'UNK': 0, 'WAS': 7, 'JAC': 4, 'KC': 3, 'PHI': 10, 'PIT': 5, 'IND': 2, 'ARI': 3, 'SF': 0, 'SD': 5}
{'MIN': 15, 'MIA': 13, 'CAR': 17, 'ATL': 18, 'DET': 19, 'CIN': 13, 'NYJ': 22, 'DEN': 19, 'BAL': 6, 'NYG': 19, 'OAK': 15, 'TEN': 14, 'NO': 15, 'DAL': 6, 'NE': 9, 'SEA': 12, 'CLE': 12, 'BUF': 14, 'STL': 18, 'CHI': 17, 'TB': 19, 'HOU': 11, 'GB': 15, 'UNK': 0, 'WAS': 13, 'JAC': 7, 'KC': 12, 'PHI': 28, 'PIT': 11, 'IND': 12, 'ARI': 19, 'SF': 12, 'SD': 11}

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