nflgame icon indicating copy to clipboard operation
nflgame copied to clipboard

Jaguars player missing team name

Open ochawkeye opened this issue 8 years ago • 15 comments

xpost: https://github.com/BurntSushi/nfldb/issues/154

import nfldb
db = nfldb.connect()
q = nfldb.Query(db)
q.game(season_year=2015, season_type='Regular', team='JAC', week=1)
q.play(play_id=3823)

for play in q.as_plays():
    print play
    for pp in play.play_players:
        print '\t', pp.team, pp.player, pp

print '-'*79

import nflgame
games = nflgame.games(year=2015, week=1, home='JAC', away='JAC')
plays = nflgame.combine_plays(games)
for play in plays.filter(playid='3823'):
    print play
    for p in play.players:
        print '\t', p.team, p.player, p.formatted_stats()
(JAC, OWN 20, Q4, 1 and 10) (2:41) (Shotgun) B.Bortles pass short middle intended for C.Harbor INTERCEPTED by T.Davis (M.Addison) at JAC 20. T.Davis to JAC 19 for 1 yard (T.Yeldon).
        JAC Blake Bortles (UNK, UNK) {'passing_int': 1, 'passing_att': 1, 'passing_incmp': 1}
        CAR Thomas Davis (CAR, OLB) {'defense_pass_def': 1, 'defense_int': 1, 'defense_int_yds': 1}
        JAC T.J. Yeldon (UNK, UNK) {'defense_tkl': 1}
        JAC Clay Harbor (NE, TE) {'receiving_tar': 1}
        CAR Mario Addison (CAR, DE) {'defense_pass_def': 1}
-------------------------------------------------------------------------------
(JAC, JAC 20, Q4, 1 and 10) (2:41) (Shotgun) B.Bortles pass short middle intended for C.Harbor INTERCEPTED by T.Davis (M.Addison) at JAC 20. T.Davis to JAC 19 for 1 yard (T.Yeldon).
        CAR Mario Addison (DE, CAR) defense_pass_def: 1
        JAC Clay Harbor (TE, NE) receiving_tar: 1
        JAC T.J. Yeldon (, ) defense_tkl: 1
        CAR Thomas Davis (OLB, CAR) defense_int: 1, defense_int_yds: 1, defense_pass_def: 1
        JAC Blake Bortles (, ) passing_int: 1, passing_att: 1, passing_incmp: 1, passing_incmp_air_yds: 0

ochawkeye avatar May 20 '16 15:05 ochawkeye

I made the following change to nflgame.update_players.py:

def roster_soup(team):
    if team == 'JAC':
        team = 'JAX'
    resp, content = new_http().request(urls['roster'] % team, 'GET')
    if resp['status'] != '200':
        return None
    return BeautifulSoup(content, PARSER)

I then re-ran nflgame-update-players and then ran my test again.

(JAC, OWN 20, Q4, 1 and 10) (2:41) (Shotgun) B.Bortles pass short middle intended for C.Harbor INTERCEPTED by T.Davis (M.Addison) at JAC 20. T.Davis to JAC 19 for 1 yard (T.Yeldon).
        JAC Blake Bortles (UNK, UNK) {'passing_int': 1, 'passing_att': 1, 'passing_incmp': 1}
        CAR Thomas Davis (CAR, OLB) {'defense_pass_def': 1, 'defense_int': 1, 'defense_int_yds': 1}
        JAC T.J. Yeldon (UNK, UNK) {'defense_tkl': 1}
        JAC Clay Harbor (NE, TE) {'receiving_tar': 1}
        CAR Mario Addison (CAR, DE) {'defense_pass_def': 1}
-------------------------------------------------------------------------------
(JAC, JAC 20, Q4, 1 and 10) (2:41) (Shotgun) B.Bortles pass short middle intended for C.Harbor INTERCEPTED by T.Davis (M.Addison) at JAC 20. T.Davis to JAC 19 for 1 yard (T.Yeldon).
        CAR Mario Addison (DE, CAR) defense_pass_def: 1
        JAC Clay Harbor (TE, NE) receiving_tar: 1
        JAC T.J. Yeldon (RB, JAC) defense_tkl: 1
        CAR Thomas Davis (OLB, CAR) defense_int: 1, defense_int_yds: 1, defense_pass_def: 1
        JAC Blake Bortles (QB, JAC) passing_int: 1, passing_att: 1, passing_incmp: 1, passing_incmp_air_yds: 0

As you can see, the Jaguar players now have a team and position assigned in nflgame (and probably will after I run nfldb-upate as well).

Of course, that team name is no longer the "NFL standard abbreviation". But at the expense of breaking the link with all old games I see that as ok?

@BurntSushi thoughts?

ochawkeye avatar May 20 '16 15:05 ochawkeye

Just a little bit more information on this one.

Navigating to page JAC returns a status of '301' (Moved Permanently) and redirects to JAX.

nflgame is not doing anything with the redirect. It simply sees that it didn't get a status of '200' and returns None.

An identical status is returned for STL which now redirects to LA.

ochawkeye avatar May 20 '16 16:05 ochawkeye

@ochawkeye I don't see the need for a code hack to handle the Jaguars team code change from JAC to JAX at least w.r.t nfldb. There is no need for it with nflgame either.

I made the following changes to my local install and both nflgame and nfldb work fine.

The database is keyed off the team code so updating it in the team table automatically propagates the change to dependent keys. The following statement addresses that:

update team set team_id = 'JAX' where team_id = 'JAC';

Updating the following entry in nfldb/team.py and nflgame/init.py: ['JAC', 'Jacksonville', 'Jaguars', 'Jacksonville Jaguars', 'JAX'], to ['JAX', 'Jacksonville', 'Jaguars', 'Jacksonville Jaguars', 'JAC'], addresses the rest of the required changes.

After these changes and running nfldb-update to update the database, running the code snippets you provided above produces the following results for the nflgame script (notice both codes in the output):

(JAC, JAC 20, Q4, 1 and 10) (2:41) (Shotgun) B.Bortles pass short middle intended for C.Harbor INTERCEPTED by T.Davis (M.Addison) at JAC 20. T.Davis to JAC 19 for 1 yard (T.Yeldon). CAR Mario Addison (DE, CAR) defense_pass_def: 1 JAC Clay Harbor (TE, NE) receiving_tar: 1 JAC T.J. Yeldon (RB, JAX) defense_tkl: 1 CAR Thomas Davis (OLB, CAR) defense_int: 1, defense_int_yds: 1, defense_pass_def: 1 JAC Blake Bortles (QB, JAX) passing_int: 1, passing_att: 1, passing_incmp: 1, passing_incmp_air_yds: 0

and the following for nfldb (the code provided in the script needs to be switched to JAX here though):

(JAX, OWN 20, Q4, 1 and 10) (2:41) (Shotgun) B.Bortles pass short middle intended for C.Harbor INTERCEPTED by T.Davis (M.Addison) at JAC 20. T.Davis to JAC 19 for 1 yard (T.Yeldon). JAX Blake Bortles (JAX, QB) {'passing_int': 1, 'passing_att': 1, 'passing_incmp': 1} JAX T.J. Yeldon (JAX, RB) {'defense_tkl': 1} JAX Clay Harbor (NE, TE) {'receiving_tar': 1} CAR Mario Addison (CAR, DE) {'defense_pass_def': 1} CAR Thomas Davis (CAR, OLB) {'defense_pass_def': 1, 'defense_int': 1, 'defense_int_yds': 1}

hpadmanabhan avatar Jun 24 '16 10:06 hpadmanabhan

Since the Rams in LA is a new team from a system perspective, the following changes suffice in adding it while maintaining the historical stats the St. Louis Rams.

Add the team to the database:

insert into team (team_id, city, name) values ('LA', 'Los Angeles', 'Rams');

Add the team in code by adding the following to nfldb/team.py and nflgame/init.py following the entry for Kansas City to keep the alphabetical listing: ['LA', 'Los Angeles', 'Rams', 'Los Angeles Rams'],

I made and tested these changes locally, can and will likely submit a patch for these changes.

hpadmanabhan avatar Jun 24 '16 10:06 hpadmanabhan

@BurntSushi will there be an update this season so JAC -> JAX and STL -> LA work out of the box? Thanks!

weixiyen avatar Jul 13 '16 13:07 weixiyen

@weixiyen Yes, I'll sort all of the critical issues out before long. I suspect preseason will be my forcing function.

BurntSushi avatar Jul 13 '16 13:07 BurntSushi

After making these mods I still don't see any STL, LA, JAC or JAX players in the player table.

artl603 avatar Jul 19 '16 11:07 artl603

Is there an update on this issue yet? I tried the solution offered by @hpadmanabhan but I still see all the players for both teams as UKN. Do I have to run a specific update command for these to work or just the regular nfldb-update?

ealco9 avatar Aug 16 '16 21:08 ealco9

@ealco9 The team rosters can be updated using the nflgame-update-players script.

bjostad avatar Aug 17 '16 17:08 bjostad

I ran that script but still nothing on the players for both LA and JAX, any other ideas? will there be an update for this?

ealco9 avatar Aug 17 '16 18:08 ealco9

To get the proper updates on my local, I followed @hpadmanabhan's instructions, then ran update queries on key JAX and LA players for the results to take effect e.g.

UPDATE public.player
   SET team='LA', "position"='RB'
 WHERE full_name='Todd Gurley';

kyleaclark avatar Sep 04 '16 22:09 kyleaclark

What about new players on LA? I have Jared Goff (00-0033106) in my players.json but I can't seem to get him to import into the DB, even with a row in the team table for LA.

dpmccabe avatar Sep 05 '16 19:09 dpmccabe

What helped me was to run the nflgame-update-players script and after running nfldb-update a couple of times it worked, I still don't really know why but what I had to do in the end was change 'JAX' to 'JAC' back again because the update script was not working. It's fine for me since I don't use the urls but it's not ideal

ealco9 avatar Sep 05 '16 21:09 ealco9

If you are having trouble getting this to update the db (and perhaps have a draft date looming), you need to force it to update the rosters by setting the player-interval to 0.

c:\anaconda2\scripts>python nfldb-update --player-interval 0
-------------------------------------------------------------------------------
STARTING NFLDB UPDATE AT 2016-09-06 11:31:31.513000
Connecting to nfldb... done.
Setting timezone to UTC... done.
Updating player JSON database... (last update was 2016-09-06 16:28:46.059000+00:00)
Loading games for POST 2015 week 5
Downloading team rosters...
33/33 complete. (100.00%)
Done!

BrutalSimplicity avatar Sep 06 '16 16:09 BrutalSimplicity

Thanks @BrutalSimplicity !!!

That worked for me. I added both of the following to my file and using @BrutalSimplicity suggesstion just above it worked and downloaded all Jags. Querying all past years data works for STL and JAC too. ['JAC', 'Jacksonville', 'Jaguars', 'Jacksonville Jaguars', 'JAC'], ['JAX', 'Jacksonville', 'Jaguars', 'Jacksonville Jaguars', 'JAX']

robertromeo5 avatar Sep 14 '16 01:09 robertromeo5