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

Season passing yards #213

Open
pzale opened this issue Nov 30, 2016 · 2 comments
Open

Season passing yards #213

pzale opened this issue Nov 30, 2016 · 2 comments

Comments

@pzale
Copy link

pzale commented Nov 30, 2016

Looking for help listing total passing yards for each team from the 2015 season. I tried this but the numbers are a little off:

db = nfldb.connect()
q = nfldb.Query(db)
q.game(season_year=2015, season_type='Regular')
plays = q.as_plays()

passyds = []

aggregated = nfldb.aggregate(plays) # Returns a list of PlayPlayer objects.
aggregated = sorted(aggregated, key=lambda p: p.passing_yds, reverse=True)
for pp in aggregated[0:32]:
passyds.append({'Team':pp.team, 'Passing Yards': pp.passing_yds})

passyds = pd.DataFrame(passyds)

print passyds

Thanks!

@sansbacon
Copy link

In my experience, the aggregate numbers are not going to perfectly match official sources but they are close enough for most purposes. If you run the example code for QB passing leaders, it is within a few yards of what is listed on other sites.

As an aside, it would be helpful to have more convenience methods to get the stats that people typically want, such as weekly and seasonal totals by team and player. The foregoing seems pretty complex just to get total passing yards for a season.

@pzale
Copy link
Author

pzale commented Nov 30, 2016

Thanks for the response. The numbers are a little off and for some reason I am getting two records for DEN with the above code. Have you found a better way to list total season stats?

Thanks.

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