Created
November 1, 2015 13:32
-
-
Save ochawkeye/d9142330323d803d8fd5 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) | |
q.game(season_year=2015) | |
q.player(full_name='Tom Brady') | |
q.play(offense_tds=1) | |
def redzone(field): | |
cutoff = nfldb.FieldPosition.from_str(field) | |
return lambda play: play.yardline >= cutoff | |
plays = filter(redzone('OPP 20'), q.as_plays()) | |
rz_tds, rz_ptds, rz_rtds = 0, 0, 0 | |
for play in plays: | |
print play | |
rz_tds += 1 | |
rz_ptds += play.passing_tds | |
rz_rtds += play.rushing_tds | |
print 'Tom Brady total redzone touchdowns:', rz_tds | |
print 'Tom Brady passing redzone touchdowns:', rz_ptds | |
print 'Tom Brady rushing redzone touchdowns:', rz_rtds |
Author
ochawkeye
commented
Nov 1, 2015
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment