This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import nfldb | |
db = nfldb.connect() | |
q = nfldb.Query(db) | |
q.game(season_year=2016, week=6) | |
for game in q.as_games(): | |
print game | |
print game.winner, game.loser |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import nflgame | |
games = nflgame.games(year=2016, kind='REG') | |
for game in games: | |
print game | |
""" | |
CAR (20) at DEN (21) | |
TB (31) at ATL (24) | |
BUF (7) at BAL (13) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Display a chart of games that have and have not yet been played for a given week.""" | |
import nflgame | |
def started_ticker(game): | |
print '{}\t{}\t\t{}'.format(game.away, game.score_away, game.time) | |
print '{}\t{}'.format(game.home, game.score_home) | |
print '-'*25 | |
def unstarted_ticker(game): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
c:\Python27\Scripts>python nfldb-update | |
------------------------------------------------------------------------------- | |
STARTING NFLDB UPDATE AT 2014-01-06 14:28:44.339000 | |
Connecting to nfldb... done. | |
Setting timezone to UTC... done. | |
Updating player JSON database... (last update was 2014-01-04 03:55:54.395000+00: | |
00) | |
Loading games for POST 2013 week 19 | |
Traceback (most recent call last): | |
File "c:\Python27\lib\runpy.py", line 162, in _run_module_as_main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
games = nflgame.games(year, week=week, kind=season_type) | |
kick_returns, punt_returns = [], [] | |
plays = nflgame.combine_plays(games) | |
playsKR = plays.filter(kickret_ret__ge=1) | |
for player in playsKR.players(): | |
kick_returns.append([ | |
str(player)+', '+player.team, | |
player.kickret_ret, | |
player.kickret_yds, | |
player.kickret_tds]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import nflgame | |
year = 2014 | |
games = nflgame.games(year) | |
players = nflgame.combine(games) | |
positions = set([p.player.position for p in players if p.player.position]) | |
# Sets up some empty dictionaries for each team to hold all of the positions | |
teams = nflgame.teams |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import nfldb | |
db = nfldb.connect() | |
q = nfldb.Query(db) | |
q.game(season_year=2015, season_type='Regular', team='NE',) | |
print len(q.as_drives()) | |
q.drive(pos_team='NE') | |
print len(q.as_drives()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import nfldb | |
db = nfldb.connect() | |
q = nfldb.Query(db) | |
team = 'MIN' | |
def redzone(field): | |
cutoff = nfldb.FieldPosition.from_str(field) | |
return lambda play: play.yardline >= cutoff |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import nfldb | |
db = nfldb.connect() | |
q = nfldb.Query(db) | |
q.game(season_year=2015) | |
q.player(full_name='Tom Brady') | |
q.play(offense_tds=1) | |
def redzone(field): | |
cutoff = nfldb.FieldPosition.from_str(field) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import nfldb | |
db = nfldb.connect() | |
q = nfldb.Query(db) | |
q.game(season_year=2015, week=7, team='MIN') | |
def redzone(field): | |
cutoff = nfldb.FieldPosition.from_str(field) | |
return lambda play: play.yardline >= cutoff |
NewerOlder