BurntSushi / nflgame

An API to retrieve and read NFL Game Center JSON data. It can work with real-time data, which can be used for fantasy football.
http://pdoc.burntsushi.net/nflgame
The Unlicense
1.27k stars 412 forks source link

Offensive plays ran by a team #338

Open naymikm opened 6 years ago

naymikm commented 6 years ago

Is there a way to access the number of offensive plays ran by each team in a game? I wrote a function to do this but it relies on some possibly unreliable specific strings in the play text.

def numPlays(year,week,team):
    games=nflgame.games(year, week=week, home=team,away=team)
    plays = nflgame.combine_plays(games)
    n = 0
    for play in plays.filter(team=team):
        if 'No Play' not in str(play) and 'kicks' not in str(play):
            n+=1
    return n