Best way to extract all Fantasy Scoring from NFLGame
Opened this issue · 1 comments
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)
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.