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) | |
p, y, w = nfldb.current(db) | |
q.game(season_type=p, season_year=y, week=w) | |
print p, y, w | |
for pp in q.sort('passing_yds').limit(10).as_aggregate(): | |
print pp.player, pp.passing_yds |
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 | |
from collections import defaultdict | |
db = nfldb.connect() | |
q = nfldb.Query(db) | |
q.game(season_year=2015, week=7) | |
results = {team[0]: {} for team in nfldb.team.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) | |
interceptions = {team[0]: 0 for team in nfldb.team.teams} | |
fumble_recoveries = {team[0]: 0 for team in nfldb.team.teams} | |
turnovers = {team[0]: 0 for team in nfldb.team.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) | |
year, week = 2015, 7 | |
q.game(season_year=year, week=week) | |
q.play(fourth_down_att=1) | |
attempts = 0 | |
att_converted = 0 | |
att_failed = 0 |
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, week = 2015, 7 | |
games = nflgame.games(year=year, week=week) | |
plays = nflgame.combine_plays(games).filter(fourth_down_att=True) | |
attempts = 0 | |
att_converted = 0 | |
att_failed = 0 | |
for play in plays: |
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 | |
NYGmisc = {} | |
db = nfldb.connect() | |
qNYG = nfldb.Query(db) | |
for gp in qNYG.play_player(team='NYG').player(position='TE').as_aggregate(): | |
# NYGmisc[gp.player] = gp <-- if you do like this, the values are class 'nfldb.query.AggPP' | |
NYGmisc[gp.player] = {field: getattr(gp, field) for field in gp.fields} # but if you do like this they are type 'dict' | |
for x in NYGmisc: | |
print type(x), type(NYGmisc[x]) |
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 | |
name = 'Amari Cooper' | |
team = 'OAK' | |
db = nfldb.connect() | |
q = nfldb.Query(db) | |
q.game(season_year=2015, season_type='Regular') | |
q.player(full_name=name, team=team) |
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=2012, season_type='Regular') | |
q.player(full_name='Julian Edelman').play_player(offense_tds=1) | |
for g in q.as_games(): | |
print g | |
print '-'*79 |
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='Preseason') | |
for game in q.as_games(): | |
print 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
import nflgame | |
games = nflgame.games(2014, week=1, kind='REG') | |
players = nflgame.combine_game_stats(games) | |
meta = nflgame.players | |
for x in players: | |
if str(x) == 'M.Ryan': | |
print x.playerid, meta[x.playerid], meta[x.playerid].gsis_name, x | |
if '.' not in str(x): |