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)


Seahawks Passing
Yards per pass attempt for R.Wilson 12.18
Opponent Passing
Yards per pass attempt for A.Rodgers 9.03

Seahawks Rushing
Yards per rush attempt for R.Wilson 3.14
Yards per rush attempt for M.Lynch 4.21
Yards per rush attempt for R.Turbin 2.71
Opponent Rushing
Yards per rush attempt for A.Rodgers -1.0
Yards per rush attempt for J.Kuhn 4.0
Yards per rush attempt for J.Starks 3.2
Yards per rush attempt for R.Cobb 2.0
Yards per rush attempt for E.Lacy 5.32

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)


Yards per rush attempt for R.Wilson 3.14
Yards per rush attempt for M.Lynch 4.21
Yards per rush attempt for R.Turbin 2.71

In [50]:


In [ ]: