Last active
November 1, 2015 13:41
-
-
Save ochawkeye/15d11329ca45c3cae7a7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Total redzone plays: 31 Redzone plays for only MIN: 19