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

Targets and Receptions are the same for players. #217

Open
theSanchize3 opened this issue Dec 10, 2016 · 3 comments
Open

Targets and Receptions are the same for players. #217

theSanchize3 opened this issue Dec 10, 2016 · 3 comments

Comments

@theSanchize3
Copy link

I am looking at the targets and receptions for an upcoming game this weekend, but I am getting the same number for both stats.
Here is the code:

for t in ['PHI','WAS']:
    q = nfldb.Query(db)
    q.game(season_year=2016,season_type='Regular',team=t)
    q.play_player(receiving_rec__ge=1,team=t)
    for p in q.sort('receiving_yds').as_aggregate():
        print p.receiving_rec,p.receiving_tar,p.player

And here is the output:

57 57 Jordan Matthews (PHI, WR)
47 47 Zach Ertz (PHI, TE)
45 45 Darren Sproles (PHI, RB)
33 33 Dorial Green-Beckham (PHI, WR)
31 31 Nelson Agholor (PHI, WR)
22 22 Trey Burton (PHI, TE)
7 7 Brent Celek (PHI, TE)
11 11 Ryan Mathews (PHI, RB)
6 6 Paul Turner (PHI, WR)
3 3 Bryce Treggs (PHI, WR)
13 13 Josh Huff (TB, WR)
6 6 Wendell Smallwood (PHI, RB)
3 3 Kenjon Barner (PHI, RB)
1 1 Carson Wentz (PHI, QB)
58 58 Jamison Crowder (WAS, WR)
59 59 Pierre Garcon (WAS, WR)
39 39 DeSean Jackson (WAS, WR)
59 59 Jordan Reed (WAS, TE)
36 36 Vernon Davis (WAS, TE)
37 37 Chris Thompson (WAS, RB)
8 8 Matt Jones (WAS, RB)
2 2 Josh Doctson (WAS, WR)
6 6 Ryan Grant (WAS, WR)
7 7 Maurice Harris (WAS, WR)
1 1 Quinton Dunbar (WAS, CB)
2 2 Niles Paul (WAS, TE)
2 2 Derek Carrier (WAS, TE)
1 1 Rashad Ross (WAS, WR)
4 4 Rob Kelley (WAS, RB)

Is there an issue with my code or is the an issue with the database?

Thanks,
Sanchez

@ochawkeye
Copy link
Contributor

ochawkeye commented Dec 10, 2016 via email

@theSanchize3
Copy link
Author

Oh, I didn't realize that. How would I get the number of targets and receptions of all the players with at least one catch on the season?

@ochawkeye
Copy link
Contributor

ochawkeye commented Dec 12, 2016

With the line q.play_player(receiving_rec__ge=1,team=t) you're throwing away all plays that didn't record a reception. Just don't do that if you want to get targets that didn't result in a reception.

import nfldb

db = nfldb.connect()
q = nfldb.Query(db)
q.game(season_year=2016, season_type='Regular')
# q.play_player(receiving_rec__ge=1)  # You are doing something like this and it is your problem
q.play_player(receiving_tar__ge=1)

for p in q.sort('receiving_tar').as_aggregate():
    if p.receiving_rec:
        print p.receiving_rec, p.receiving_tar, p.player
80 144 Mike Evans (TB, WR)
93 138 Antonio Brown (PIT, WR)
79 134 Odell Beckham (NYG, WR)
92 131 Larry Fitzgerald (ARI, WR)
75 128 Emmanuel Sanders (DEN, WR)
78 127 T.Y. Hilton (IND, WR)
75 125 Jordy Nelson (GB, WR)
76 119 Demaryius Thomas (DEN, WR)
71 119 Michael Crabtree (OAK, WR)
57 118 Allen Robinson (JAC, WR)
63 117 Terrelle Pryor (CLE, WR)
59 116 DeAndre Hopkins (HOU, WR)
57 114 Brandon Marshall (NYJ, WR)
73 114 Amari Cooper (OAK, WR)
72 113 Julio Jones (ATL, WR)
...

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