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
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
from __future__ import absolute_import, division, print_function | |
import nfldb | |
def nfldb_pp_func(db, nflgame_name): | |
""" | |
nflgame player name -> nfldb play player | |
P.Manning, DEN -> Peyton Manning (DEN, QB) | |
""" |
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): |
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 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 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 | |
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 | |
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 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: |
OlderNewer