Skip to content

Instantly share code, notes, and snippets.

@ochawkeye
Last active November 1, 2015 13:41
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/15d11329ca45c3cae7a7 to your computer and use it in GitHub Desktop.
Save ochawkeye/15d11329ca45c3cae7a7 to your computer and use it in GitHub Desktop.
import nfldb
db = nfldb.connect()
q = nfldb.Query(db)
team = 'MIN'
def redzone(field):
cutoff = nfldb.FieldPosition.from_str(field)
return lambda play: play.yardline >= cutoff
q.game(season_year=2015, week=7, team=team)
plays = filter(redzone('OPP 20'), q.as_plays())
print 'Total redzone plays: {}'.format(len(plays))
q.game(season_year=2015, week=7, team=team)
q.play(pos_team=team) # This is what tosses out the "defensive" redzone plays
plays = filter(redzone('OPP 20'), q.as_plays())
print 'Redzone plays for only {}: {}'.format(team, len(plays))
@ochawkeye
Copy link
Author

Total redzone plays: 31
Redzone plays for only MIN: 19

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