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

Best way to extract all Fantasy Scoring from NFLGame #323

Open
irish1986 opened this issue Sep 10, 2017 · 1 comment
Open

Best way to extract all Fantasy Scoring from NFLGame #323

irish1986 opened this issue Sep 10, 2017 · 1 comment

Comments

@irish1986
Copy link

irish1986 commented Sep 10, 2017

I am still fairly new to Python and Git, if this isn't the right location to post this question please instruct me.

I wish to extract all scoring play and apply a standard FF scoring schema to compare actual versus projection. Surprisingly enough I was expecting something in the cookbook but maybe I didn't find it.

So how can I load all scoring play for Week 1 2017 in a Pandas DF ?

EDIT: Here the code I have so far, just looking for advice.

import nflgame

players = nflgame.combine_game_stats(nflgame.games(2017, 1))

scoring = {
    # Passing
    'passing_yds' : lambda x : x*.04,
    'passing_tds' : lambda x : x*4,
    'passing_twoptm'  : lambda x : x*2,
    # Rushing
    'rushing_yds' : lambda x : x*.1 + (2 if x >= 100 else 0),
    'rushing_tds' : lambda x : x*6,
    'kickret_tds' : lambda x : x*6,
    'rushing_twoptm' : lambda x : x*2,
    # Receiving
    'receiving_tds' : lambda x : x*6,
    'receiving_yds' : lambda x : x*.1 + (2 if x >= 100 else 0),
    'receiving_rec' : lambda x : x*.5,
    'receiving_twoptm' : lambda x : x*2,
    # Various
    'fumbles_lost' : lambda x : x*-2, 
    'passing_ints' : lambda x : x*-2,
}

def score_player(player):
    score = 0
    for stat in player._stats:
        if stat in scoring:
            score += scoring[stat](getattr(player,stat))    
    return score

for p in players.limit(10):
    score = score_player(p)
    print (p,score)
@derek-adair
Copy link
Contributor

You may get more advice on a site like stackoverflow or https://softwareengineering.stackexchange.com.
This LOOKS like a good start, knowing nothing of fantasy football .

If you are looking for something you can just plug-n-play you may try browsing the network of repo's that have forked.

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