Skip to content
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

fix [home|away]_turnovers #197

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

Conversation

gt6796c
Copy link

@gt6796c gt6796c commented Sep 22, 2016

This addresses a discrepancy between the game.xxx_turnovers in the game table and the incoming JSON from nfl.com
I don't know what 'to' is, but I'm fairly certain that it is not turnovers as the data doesn't match up with the play-by-play data. The changes here make the statistical category match up with the play-by-play.

Unfortunately, the existing data is already wrong since these values are written to the db. The following code fixes up the DB.

with nfldb.Tx(db) as cursor:
  cursor.execute("SET TIME ZONE 'UTC'")
  for year in range(start, end+1):
      games = nflgame.games(year)
      for game in games:
        dbg = nfldb.Game.from_id(db,game.eid)
        dbg.home_turnovers = int(game.data['home']['stats']['team']['trnovr'])
        dbg.away_turnovers = int(game.data['away']['stats']['team']['trnovr'])
        dbg._save(cursor)

Copy link
Contributor

@ochawkeye ochawkeye left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that is actually reflecting the number of timeouts that a team has remaining at the end of the game.

in 2009081551, Chicago and Buffalo both called 2 first half timeouts. In the second half, Chicago called 3 timeouts and Buffalo called 1 timeout.

@ochawkeye
Copy link
Contributor

Thanks for stripping all of my comments new github (has to be their fault and not me not knowing how to use their system!)

http://www.nfl.com/gamecenter/2009081551/2009/PRE1/bears@bills#menu=gameinfo%7CcontentId%3A09000d5d811ed31d&tab=analyze&analyze=playbyplay

Chicago threw 4 interceptions and lost 1 fumble but ['away']['to'] == 0.
Buffalo threw 1 interception and lost 2 fumbles but ['home']['to'] == 2.

@gt6796c
Copy link
Author

gt6796c commented Sep 22, 2016

That was my thought as well. 2015101103 was what I was looking at. ATL should have had 3 turnovers. Didn't find something that told me how many timeouts they had left so I could confirm what exactly 'to' was. Ended up doing a search in the DB and all turnovers were between 0 and 3. That seemed.... unlikely.

This was referenced Oct 29, 2017
joeycortez42 added a commit to joeycortez42/nfldb that referenced this pull request Nov 15, 2017
Modified version of BurntSushi#197.

Fixed home_turnovers and away_turnovers mapping from timeout mapping.
Added command line option to update game turnovers.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants