-
Notifications
You must be signed in to change notification settings - Fork 413
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to detect blocked punts recovered for a TD #330
Comments
import nflgame
games = nflgame.games(2017, 1, kind='REG')
plays = nflgame.combine_plays(games).filter(defense_puntblk__ge=1, touchdown__ge=1)
for play in plays:
print play
Looks like there were two punt blocks for touchdown last season. import nflgame
games = nflgame.games(2016, kind='REG')
plays = nflgame.combine_plays(games).filter(defense_puntblk__ge=1, touchdown__ge=1)
for play in plays:
print play
|
Edit: Nevermind, figured out my bug. Thanks, this works perfectly!! |
I want to amend my original answer a bit. By doing import nflgame
games = nflgame.games(year=2014, kind='REG')
plays = nflgame.combine_plays(games).filter(defense_puntblk=True, touchdown=True)
print len([p for p in plays]) # 10
plays = nflgame.combine_plays(games).filter(defense_puntblk=True, defense_tds=True)
print len([p for p in plays]) # 10
plays = nflgame.combine_plays(games).filter(defense_puntblk=True, touchdown=True, defense_tds=False)
print len([p for p in plays]) # 0
I'm having trouble deciphering your code in that format, but aren't you already determining the defensive team in most every line in your OP (ie. def defense_on_field(play):
if play.home: # play.home == True if home team has the ball
return play.drive.game.away
return play.drive.game.home I'm curious how using the import nflgame
def defense_on_field(play):
if play.home: # play.home == True if home team has the ball
return play.drive.game.away
return play.drive.game.home
games = nflgame.games(year=2017, week=1, kind='REG')
plays = nflgame.combine_plays(games).filter(defense_tds=True)
for play in plays:
print 'Defense:', defense_on_field(play), 'in play:', play
|
So you're saying I can just filter by "defense_tds" and I don't have to look for all the possible Defensive TDs? Is there also a Special Teams TD or do I still need to look for kickoff returns and punt returns? Where do you see all the options you can filter plays by? Thanks again! |
The wiki has a table with stat types though in truth I probably end up stumbling upon much of what I use by random inspection. For example, in the initial code I posted to your question, printing import nflgame
games = nflgame.games(year=2017, week=1, kind='REG')
plays = nflgame.combine_plays(games).filter(defense_puntblk=True, touchdown=True)
for play in plays:
print play
print '-'*25
print dir(play)
Looking at that, I noticed the |
Cool, I will look into this a little more tonight. Thanks for your help! |
So I am trying to see how many "defensive" touchdowns a team has and I have the following block in a for-loop:
numDefTDs = 0 for play in nflgame.combine_plays(week).filter(defense_frec_tds=True): # play.team shows the offense that gave up the TD # so if play.team is the same as game.away, our defense got the fum rec td if play.team == game.away: numDefTDs += 1 for play in nflgame.combine_plays(week).filter(defense_int_tds=True): # play.team shows the offense that gave up the TD # so if play.team is the same as game.away, our defense got the int td if play.team == game.away: numDefTDs += 1 for play in nflgame.combine_plays(week).filter(kickret_tds=True): # play.team shows the offense that gave up the TD # so if play.team is the same as game.away, our defense got the kick ret td if play.team == game.away: numDefTDs += 1 for play in nflgame.combine_plays(week).filter(puntret_tds=True): # play.team shows the offense that gave up the TD # so if play.team is the same as game.away, our defense got the punt ret td if play.team == game.away: numDefTDs += 1
So I am gathering INT and fumble recovery TDs plus punt and kickoff returns and this has worked fine for the past couple years. But in the Pittsburgh/Cleveland game, Pittsburgh blocked a punt and recovered it for a TD. Is there a stat to show this? Thanks!
The text was updated successfully, but these errors were encountered: