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

Jaguars player missing team name #201

Open
ochawkeye opened this issue May 20, 2016 · 15 comments
Open

Jaguars player missing team name #201

ochawkeye opened this issue May 20, 2016 · 15 comments

Comments

@ochawkeye
Copy link
Contributor

xpost: BurntSushi/nfldb#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
Copy link
Contributor Author

ochawkeye commented May 20, 2016

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
Copy link
Contributor Author

ochawkeye commented May 20, 2016

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.

@hpadmanabhan
Copy link

hpadmanabhan commented Jun 24, 2016

@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
Copy link

hpadmanabhan commented Jun 24, 2016

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.

@weixiyen
Copy link
Contributor

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

@BurntSushi
Copy link
Owner

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

@artl603
Copy link

artl603 commented Jul 19, 2016

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

@ealco9
Copy link

ealco9 commented Aug 16, 2016

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?

@bjostad
Copy link

bjostad commented Aug 17, 2016

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

@ealco9
Copy link

ealco9 commented Aug 17, 2016

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?

@kyleaclark
Copy link

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';

@dpmccabe
Copy link

dpmccabe commented Sep 5, 2016

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.

@ealco9
Copy link

ealco9 commented Sep 5, 2016

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

@BrutalSimplicity
Copy link

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!

@robertromeo5
Copy link

robertromeo5 commented Sep 14, 2016

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']

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

No branches or pull requests