nfldb icon indicating copy to clipboard operation
nfldb copied to clipboard

Post Season

Open mrg1999 opened this issue 9 years ago • 26 comments

Are stats available for the post season (game day, game time)? I've tried: q = nfldb.Query(db) q.game(season_year=2015, season_type='Postseason', week = 1) for g in q.as_games(): print g

I've also tried no week and week = 18 with the season_type set to 'Regular' and 'Postseason'

mrg1999 avatar Jan 09 '16 17:01 mrg1999

Update nfldb, e.g., pip install --upgrade nfldb and re-run nfldb-update.

BurntSushi avatar Jan 09 '16 17:01 BurntSushi

Perfect, Thanks

mrg1999 avatar Jan 09 '16 22:01 mrg1999

Thanks!

pla1 avatar Jan 10 '16 00:01 pla1

Is this something I should be doing on a regular basis?

mrg1999 avatar Jan 10 '16 04:01 mrg1999

@mrg1999 At the very least, when the season transitions to the postseason, then you should. If you want to get bug fixes, then you should do it on a regular basis.

BurntSushi avatar Jan 10 '16 04:01 BurntSushi

Hello, even after running pip install --upgrade nfldb and pip install --upgrade nflgame and nfldb-update, I still only get the first week of postseason games (and oddly the super bowl game scheduled). I've attached a screenshot of the output I get from an example query: screen shot 2016-02-05 at 8 24 50 am

Did the data format of the games in postseason weeks after 1 change by the NFL? Is anyone else seeing this problem.

tarlen5 avatar Feb 05 '16 16:02 tarlen5

So weird that this is popping up so frequently... image

I'm at a loss for why those items that appear in the schedule aren't showing up for you.

ochawkeye avatar Feb 05 '16 16:02 ochawkeye

I'm on a mac and it looks like you're running windows (and I think the system was originally developed for linux) so maybe that's a clue to the problem?

tarlen5 avatar Feb 05 '16 18:02 tarlen5

You might be on to something there... screenshot from 2016-02-05 18 19 46 screenshot from 2016-02-05 18 35 08

ochawkeye avatar Feb 05 '16 18:02 ochawkeye

Hello, I recently grabbed a copy of the database and noticed the same problem. I'm running windows. I did a straight sql query: postseason_query

Remedine avatar Mar 11 '16 08:03 Remedine

I'm in the same situation as @Remedine, I ran pip install --upgrade nfldb and nfldb-update. I only have those 5 Postseason games.

jcapron avatar Apr 09 '16 17:04 jcapron

Me too, I installed everything this weekend on a server with Ubuntu 12.04.

I ran I ran pip install --upgrade nfldb, pip install --upgrade nflgame and nfldb-update and I still have only 5 postseason games in the DB.

Then I tried to run pip install --upgrade nfldb, pip install --upgrade nflgame and nfldb-update --update-schedules with no change.

2015_postseason

danielcroona avatar Apr 11 '16 07:04 danielcroona

I ran into the same problem on a Linux box and updating nfldb as outlined above by @BurntSushi did not resolve the issue. The problem seems to be with nflgame not updating schedule.json with the schedules for those game which results in the gamecenter json data for those games not being downloaded when nfldb-update is run. Unclear why this is so.

I was able to however resolve this issue by manually rebuilding the 2015 postseason schedule by running: <python 2 home lib>/site-packages/nflgame/update_sched.py --rebuild --year 2015 --phase POST

then running nfldb-update again once the schedule.json file was update by the above.

This resolution was also highlighted by @ochawkeye as a possible solution under this issue reported for nflgame.

hpadmanabhan avatar Jun 20 '16 01:06 hpadmanabhan

@hpadmanabhan This worked! Thanks!

tstewart15 avatar Jun 21 '16 02:06 tstewart15

After reviewing the code further the issue as I see it is that nfldb-update relies on nflgame schedule JSON being up-to-date to load all updates. Keeping the nflgame JSON up-to-date however with the current code requires that nfldb-update be run continually in sync with season phases so schedule updates are picked up in a timely manner when the season transitions from regular to post as the schedule sources for the two are different and the switch in source is currently manual.

The issue of having to wait for @BurntSushi to switch the source when transitioning from regular to post season and vice versa is an issue in the nflgame code that needs to be addressed separately.

The additional issue with nfldb is that if you don't get the code updates right away and run nfldb-update you end up with this issue where you only get the updates for whatever schedule updates got pushed in schedule.json (playoff week 1) with the patch and whatever the current week happens to be (playoff week 5). To get the missing interim data you have to separately run a nflgame schedule update as outlined by me above. To resolve this on the nfldb side I have uploaded a patch whereby running nfldb-update --update-schedules will now implicitly rebuild the nflgame schedule.json file adding in the schedule for all the games in the interim and running nfldb-update again right after will load all the schedule and game data to the database. Once @BurntSushi reviews, accepts and publishes it this issue should be resolved.

hpadmanabhan avatar Jun 21 '16 07:06 hpadmanabhan

Just chiming in to mention this is still an issue. I updated nflgame, nfldb, ran "nfldb-update --update-schedules ", but still had to run "<python 2 home lib>/site-packages/nflgame/update_sched.py --rebuild --year 2016 --phase POST" to get last weeks games in. No biggie, thanks for fix here!!

jimmylowell avatar Jan 12 '17 20:01 jimmylowell

If nothing else works you can simply edit the file /nflgame/live.py and change the variable: _CUR_SCHEDULE to "http://www.nfl.com/liveupdate/scorestrip/postseason/ss.xml"

i.e.

_CUR_SCHEDULE = "http://www.nfl.com/liveupdate/scorestrip/postseason/ss.xml"

danielcroona avatar Jan 13 '17 07:01 danielcroona

I wasn't getting any of postweek 1 scores so I rebuilt the schedule file with

/site-packages/nflgame/update_sched.py --rebuild --year 2016 --phase POST Question: will I need to run this every week during the post season? Thanks!

mrg1999 avatar Jan 14 '17 14:01 mrg1999

You shouldn't have to rebuild it every week, no. To tell you the truth, though, I'm not sure why you had to last week.

After updating nflgame to grab the proper schedule URL for the playoffs nfldb just worked for me.

On Jan 14, 2017 8:35 AM, "mrg1999" [email protected] wrote:

I wasn't getting any of postweek 1 scores so I rebuilt the schedule file with

/site-packages/nflgame/update_sched.py --rebuild --year 2016 --phase POST Question: will I need to run this every week during the post season? Thanks!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/BurntSushi/nfldb/issues/136#issuecomment-272627903, or mute the thread https://github.com/notifications/unsubscribe-auth/AC237Qs2e5H8zghKopkzoOkDfzPX4vY4ks5rSN0YgaJpZM4HBuZf .

ochawkeye avatar Jan 14 '17 16:01 ochawkeye

Looks like I'm updating nfldb only. Is that the nflgame-update-players file in the scripts folder?

mrg1999 avatar Jan 14 '17 16:01 mrg1999

nfldb-update automatically refreshes the current week's schedule of games from nflgame.

Not knowing when you ran which commands I'd just be guessing. If you ran nfldb-update after the NFL flipped the calendar to week 2, that might have missed week 1 games, not sure.

I will say this: if you are successfully able to currently see Wildcard results I'm confident that 1) nflgame.live._CUR_SCHEDULE is set to properly pull playoff schedule and 2) your setup should run no problem today for the Divisional round.

An easy way to check if your nflgame schedule has today's games:

import nflgame
for game in nflgame.live._games_in_week(2016, 2, 'POST'):
    print game
{u'week': 2, u'meridiem': u'PM', u'gamekey': u'57161', u'season_type': u'POST', u'away': u'SEA', u'year': 2016, u'month': 1, u'eid': u'2017011400', u'time': u'4:35', u'home': u'ATL', u'wday': u'Sat', u'day': 14}
{u'week': 2, u'meridiem': u'PM', u'gamekey': u'57162', u'season_type': u'POST', u'away': u'HOU', u'year': 2016, u'month': 1, u'eid': u'2017011401', u'time': u'8:15', u'home': u'NE', u'wday': u'Sat', u'day': 14}
{u'week': 2, u'meridiem': u'AM', u'gamekey': u'57163', u'season_type': u'POST', u'away': u'PIT', u'year': 2016, u'month': 1, u'eid': u'2017011500', u'time': u'8:20', u'home': u'KC', u'wday': u'Sun', u'day': 15}
{u'week': 2, u'meridiem': u'PM', u'gamekey': u'57164', u'season_type': u'POST', u'away': u'GB', u'year': 2016, u'month': 1, u'eid': u'2017011501', u'time': u'4:40', u'home': u'DAL', u'wday': u'Sun', u'day': 15}

Or with nfldb after running nfldb-update

import nfldb
db  = nfldb.connect()
q = nfldb.Query(db)
q.game(season_year=2016, season_type='Postseason')
for game in q.as_games():
    print game
Postseason 2016 week 1 on 01/07 at 03:35PM, OAK (14) at HOU (27)
Postseason 2016 week 1 on 01/07 at 07:15PM, DET (6) at SEA (26)
Postseason 2016 week 1 on 01/08 at 12:05PM, MIA (12) at PIT (30)
Postseason 2016 week 1 on 01/08 at 03:40PM, NYG (13) at GB (38)
Postseason 2016 week 2 on 01/14 at 03:35PM, SEA (0) at ATL (0)
Postseason 2016 week 2 on 01/14 at 07:15PM, HOU (0) at NE (0)
Postseason 2016 week 2 on 01/15 at 07:20PM, PIT (0) at KC (0)
Postseason 2016 week 2 on 01/15 at 03:40PM, GB (0) at DAL (0)

ochawkeye avatar Jan 14 '17 17:01 ochawkeye

After /site-packages/nflgame/update_sched.py --rebuild --year 2016 --phase POST and nfldb-update I ran your script above and got the correct result. My program currently runs a pip install --upgrade nfldb script at the beginning of the season, at the start of the regular season and at the beginning of the post season I'm going to incorporate pip install --upgrade nflgame into that schedule. Yes/No ?

mrg1999 avatar Jan 14 '17 18:01 mrg1999

That works only if the versions of nfldb & nflgame that live on PyPI are kept up to date. Since nflgame and nfldb haven't been updated there since September it wouldn't do much to help you with this issue.

ochawkeye avatar Jan 14 '17 19:01 ochawkeye

Manually updating nflgame & nfldb fixed this issue for me.

Related issue I didn't see elsewhere: Can Query handle aggregating regular season & postseason results?

For example:

q = nfldb.Query(db) q.game(season_year= season, season_type= 'Postseason') q.game(season_year= season, week = [17], season_type = 'Regular')

for i in q.as_games(): print i

... does not return anything. Whereas each separate q.game(season_type = '') query does. Any suggestions on how to aggregate other than running separately and combining manually?

kennysushi avatar Jan 19 '17 23:01 kennysushi

Editing this down to one comment so I don't look like a crazy(-ier) person when I look back on this post a year from now.

When you tell nfldb q.game(season_year= season, season_type= 'Postseason') you're telling it to throw out anything that isn't a Postseason game from the season in question. Your next command q.game(season_year= season, week = [17], season_type = 'Regular') says, "ok, now with what remains, give me just the games that occurred in week 17 of the regular season". There aren't any games that meet that criteria.

Your query of grabbing only the last 3 weeks of the regular season and first 2 weeks of the postseason presents an interesting challenge and one that isn't directly referenced in the wiki

A way to combine these separate queries is by joining the conjunctive queries disjunctively with the QueryOR function and .orelse (are you threatening me?)

import nfldb
db = nfldb.connect()

end_of_reg = nfldb.Query(db)
end_of_reg.game(season_year=2016, season_type='Regular', week=[15, 16, 17])

beg_of_post = nfldb.Query(db)
beg_of_post.game(season_year=2016, season_type='Postseason', week=[1, 2])  

last_five_games = nfldb.QueryOR(db)
last_five_games.orelse(end_of_reg)
last_five_games.orelse(beg_of_post)

print len(last_five_games.as_games())
56

Sorry for the stream of self-replies and if I sound like a total ass it's because I'm using words that have never come out of my own mouth before and are more or less vocabulary out of @BurntSushi wiki entry and rearranged to express the opposite concept.

ochawkeye avatar Jan 20 '17 04:01 ochawkeye

Not at all! Thank you for the lengthy explanation. I saw "andalso" in the documentation but missed "orelse". Good find!

kennysushi avatar Jan 20 '17 16:01 kennysushi