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

Two passing leaders for each team #204

Open
paulz1 opened this issue Oct 25, 2016 · 1 comment
Open

Two passing leaders for each team #204

paulz1 opened this issue Oct 25, 2016 · 1 comment

Comments

@paulz1
Copy link

paulz1 commented Oct 25, 2016

Probably I do something wrong... but here is my problem.
I try to find 2 passing leaders for each team for each season.

I have a list of all teams, so I do a loop over all teams and all years.

years=range(2009,2016)
for cur_year in years :
    print cur_year
    for cur_team in all_teams :
        print cur_team
        cur_query=nfldb.Query(db)
        cur_query.game(season_year=cur_year, season_type='Regular',team=cur_team)
        cur_query.player(team=cur_team)
        for pp in cur_query.sort('passing_yds').limit(2).as_aggregate():
            print pp.player, pp.passing_yds
        print "______________"

For the moment I have at least two problems with 2015 season.

a) No data for STL;
b) No data for DEN

Probably because Case Keenum play now for LA and Nick Foles for KC.
The same for Denver, because Peyton Manning marked as UNK.

I could remove the line cur_query.player(team=cur_team),
but in this case I get not the two bests passers of the team, but the best passer of the team and his best opponent passer for this season.

Example for 2015 for NYJ I got :

NYJ
Ryan Fitzpatrick (NYJ, QB) 3905
Tom Brady (NE, QB) 586

So, probably it's not an issue... but may be you could give a clue how I could solve this problem?

@sansbacon
Copy link

it might relate to this:

game.players is a list of tuples of player data. The first element is the team the player was on during the game and the second element is a Player object corresponding to that player's meta data (including the team he's currently on).

Cur_team is the team the player is currently on, not necessarily the team he was on when the game was played?

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

2 participants