BurntSushi / nfldb

A library to manage and update NFL data in a relational database.
The Unlicense
1.07k stars 263 forks source link

Inconsistent Turnover Data #280

Closed joeycortez42 closed 6 years ago

joeycortez42 commented 6 years ago

Turnovers in nflgame and nfldb are a mess.

Sometimes the NFL's JSON data for team stats reports total turnovers and sometimes it reports "net turnovers" (i.e. fumbles lost only). nfldb's game table is supposed to be taking nflgame ['stats']['team']['trnovr'] but for some reason those are not matching either. The mappings in pull request #197 look right so the I'm not sure where the error occurs.

Turnovers should probably be an aggregate of INTs + Lost fumbles. That way game turnovers can be used to calculate team turnover differential. Individual player fumbles can always be determined on a player level.

joeycortez42 commented 6 years ago

Tested a version of pull request #197 and it works. nfldb games now reports the proper turnover totals.

I checked the totals for the 2017 Ravens over the first 8 weeks of 2017 to confirm using:

import nflgame
game = nflgame.one(2017, 1, 'CIN', 'BAL')
print game.home, game.stats_home.turnovers, 'turnovers'
print game.away, game.stats_away.turnovers, 'turnovers'

for p in game.players:
    if p.fumbles_lost > 0 or p.passing_ints > 0:
        print p, p.fumbles_lost, 'fumbles lost', p.passing_ints, 'ints'
joeycortez42 commented 6 years ago

281 is a refresh of #197 and solves the turnover data issue.