GithubHelp home page GithubHelp logo

Comments (7)

BurntSushi avatar BurntSushi commented on July 20, 2024

Yuck.

As of now, nfldb gets team and position data for players based on the current team roster. Take a look at the SEA and ATL rosters: http://www.nfl.com/teams/seattleseahawks/roster?team=SEA and http://www.nfl.com/teams/seattleseahawks/roster?team=ATL

See anything missing?

So that's why. The question is now, what to do about it.

I'll look into pulling team/position data from their profile page and the team's roster page.

from nfldb.

oliverjen avatar oliverjen commented on July 20, 2024

Ah, it would work perfectly during the season. But during the offseason, when a roster churns, it could be out of whack. Thanks for looking at it, Andrew!

from nfldb.

gojonesy avatar gojonesy commented on July 20, 2024

I think that an issue that I am facing is related to this as well...

I am trying to aggregate a team's forced fumbles for 2013. In this example, Arizona:

import nfldb

db = nfldb.connect()
q = nfldb.Query(db)

q.game(season_year=2013, season_type='Regular', team='ARI')
# Get all Forced Fumbles
q.play(pos_team__ne='ARI', down__ne=0)
plays = q.as_plays()
run_total = 0
aggregated = nfldb.aggregate(plays)
aggregated = sorted(aggregated, key=lambda p: p.defense_ffum, reverse=True)
for pp in aggregated:
    if pp.team == "ARI":
        print pp.player, pp.defense_ffum
        run_total += pp.defense_ffum

print run_total

output:

John Abraham (ARI, OLB) 4
Jerraud Powers (ARI, CB) 1
Tyrann Mathieu (ARI, FS) 1
Darnell Dockett (ARI, DE) 1
Calais Campbell (ARI, DE) 1
Sam Acho (ARI, OLB) 1
Matt Shaughnessy (ARI, OLB) 1
Marcus Benard (ARI, LB) 1
Jasper Brinkley (MIN, ILB) 0
Rashad Johnson (ARI, FS) 0
Lorenzo Alexander (ARI, OLB) 0
Karlos Dansby (CLE, ILB) 0
Yeremiah Bell (UNK, UNK) 0
Dan Williams (ARI, NT) 0
Patrick Peterson (ARI, CB) 0
Antoine Cason (CAR, CB) 0
Frostee Rucker (ARI, DE) 0
Tony Jefferson (ARI, FS) 0
Justin Bethel (ARI, CB) 0
Ronald Talley (ARI, DE) 0
Javier Arenas (ATL, CB) 0
Alameda Ta'amu (ARI, NT) 0
Kenny Demens (ARI, ILB) 0
Dontay Moch (CIN, LB) 0
Daryl Washington (ARI, ILB) 0
Jaron Brown (ARI, WR) 0
Bryan McCann (ARI, DB) 0
11

You will notice that many of these players played for ARI in 2013, but they are listed on another team now. No problem with that. The issue here is that Karlos Dansby had a Forced Fumble last year that is not listed.

It seems way more likely that there is something wrong with my code, but I ran across this today and recalled this issue.

Do you think this is related?

from nfldb.

BurntSushi avatar BurntSushi commented on July 20, 2024

@gojonesy No, it's probably not related. Player affiliations don't really have anything to do with the connection between players and statistics. A single missing forced fumble among otherwise correct data probably just indicates that the source data was wrong. (Although to verify, you should try and locate the specific play where it occurred and see if it's logged in nfldb or possibly nflgame.)

I did try out your code and I think it's right. But I simplified it for you:

import nfldb

db = nfldb.connect()
q = nfldb.Query(db)

q.game(season_year=2013, season_type='Regular', team='ARI')
q.play(team='ARI', pos_team__ne='ARI', down__ne=0)

run_total = 0
for pp in q.sort('defense_ffum').as_aggregate():
    print pp.player, pp.defense_ffum
    run_total += pp.defense_ffum
print run_total

The key is taking advantage of the team field on the play_player table. You were half way there with pos_team__ne='ARI' (which is an attribute of a play).

Also, aggregating and sorting inside the database is much faster. :-)

from nfldb.

gojonesy avatar gojonesy commented on July 20, 2024

Thanks for that Andrew. That seems way more efficient.

Dansby still doesn't show a Forced Fumble. NFL.com shows that he had one on 10/13 against San Francisco.

I may have just stumbled across a random data inconsistency...

Thanks for your help

from nfldb.

BurntSushi avatar BurntSushi commented on July 20, 2024

I may have just stumbled across a random data inconsistency...

This isn't improbable. There are a lot of data inaccuracies, unfortunately. I did a test measuring inaccuracies last season: https://github.com/BurntSushi/nflgame/tree/master/test-data/results-yahoo-2012-max

You can see, for example, the results of defensive end stats: https://github.com/BurntSushi/nflgame/blob/master/test-data/results-yahoo-2012-max/de.tsv --- There are several players with slightly off forced fumble statistics, tackles, etc.

(Note that the players that are waaaay off are likely a result of an invalid player match in my test rather than actual inaccuracies.)

FYI, there's really nothing we can do. These are straight from the JSON data.

from nfldb.

BurntSushi avatar BurntSushi commented on July 20, 2024

Closing this for now. I think the kinks may have worked themselves out.

Note though that there are still a bunch of players who don't have gsis identifiers yet. This will produce some vomit if you run nfldb-update and it tries updating the player meta data. This is OK and it should hopefully start to disappear as we get closer to the season.

from nfldb.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.