Calculate yards per pass attempt for last game, for Seahawks and their next opponent.
In [17]:
import nflgame
import numpy
import matplotlib.pyplot as plt
from pylab import *
from __future__ import division
Set next opponent.
In [18]:
next_opp = 'GB'
Get last game for each team.
In [19]:
sea_game = nflgame.one(2014, 2, "SEA", "SEA", kind='POST')
opp_game = nflgame.one(2014, 2, next_opp, next_opp, kind='POST')
Build functions.
In [20]:
def yards_pp_att(self):
yppa = round(self.passing_yds / self.passing_att, 2)
return yppa
In [21]:
def yards_per_rush(self):
ypra = round(self.rushing_yds / self.rushing_att, 2)
return ypra
In [22]:
print 'Seahawks Passing'
for p in sea_game.players.passing().filter(home=True):
print 'Yards per pass attempt for', p, yards_pp_att(p)
print 'Opponent Passing'
for p in opp_game.players.passing().filter(home=True):
print 'Yards per pass attempt for', p, yards_pp_att(p)
print''
print 'Seahawks Rushing'
for p in sea_game.players.rushing().filter(home=True):
print 'Yards per rush attempt for', p, yards_per_rush(p)
print 'Opponent Rushing'
for p in opp_game.players.rushing().filter(home=True):
print 'Yards per rush attempt for', p, yards_per_rush(p)
In [50]:
year = 2014
week = 2
team = "SEA"
kind = 'POST'
dea_game = nflgame.one(year, week, team, team, kind=kind)
for p in dea_game.players.rushing().filter(home=True):
print 'Yards per rush attempt for', p, yards_per_rush(p)
In [50]:
In [ ]: