In [5]:
import pandas as pd
import matplotlib as mp
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.patches as mpatches

rb_games = pd.read_csv('rb_games.csv')
rb_games.columns.values


Out[5]:
array(['Name', 'Year', 'Career Year', 'GameCount', 'Career Games', 'Date',
       'Team', 'Opp', 'Result', 'Rush Att', 'Rush Yds', 'Rush Avg',
       'Rush Lg', 'Rush TD', 'Rush FD', 'Rec Rec', 'Rec Yds', 'Rec Avg',
       'Rec Lg', 'Rec TD', 'Rec FD', 'Rec Tar', 'Rec YAC'], dtype=object)

In [6]:
rb_games['Fantasy Points'] = ((rb_games['Rush Yds'] + rb_games['Rec Yds']) / 10) + ((rb_games['Rush TD'] + rb_games['Rec TD']) *6)
rb_fantasy = rb_games[['Name','Career Year', 'Year', 'GameCount', 'Career Games', 'Date', 'Rec Rec', 'Rec Yds', 'Rec TD', 'Rush Att', 'Rush Yds', 'Rush TD', 'Fantasy Points']]

rb_fantasy.head(10)


Out[6]:
Name Career Year Year GameCount Career Games Date Rec Rec Rec Yds Rec TD Rush Att Rush Yds Rush TD Fantasy Points
0 brown, aaron 1 2009 1 1 9/13/09 0 0 0 1 9 0 0.9
1 brown, aaron 1 2009 2 2 9/20/09 1 3 0 4 10 0 1.3
2 brown, aaron 1 2009 3 3 9/27/09 1 9 0 5 6 0 1.5
3 brown, aaron 1 2009 4 4 10/4/09 1 14 0 1 3 0 1.7
4 brown, aaron 1 2009 5 5 10/11/09 0 0 0 0 0 0 0.0
5 brown, aaron 1 2009 6 6 10/18/09 0 0 0 2 13 0 1.3
6 brown, aaron 1 2009 7 7 11/1/09 2 13 0 2 15 0 2.8
7 brown, aaron 1 2009 8 8 11/8/09 0 0 0 4 27 0 2.7
8 brown, aaron 1 2009 9 9 11/22/09 1 26 1 0 0 0 8.6
9 brown, aaron 1 2009 10 10 11/26/09 0 0 0 1 5 0 0.5

In [7]:
rb_2016 = rb_games.loc[(rb_games.Year == 2016) & (rb_games.GameCount < 19)]
print(len(rb_2016))
rb_2016_sum = rb_2016.groupby(['Name', 'Year'], as_index=False).sum()[['Name', 'Rush Yds', 'Rush TD', 'Rec Yds', 'Rec TD', 'Fantasy Points']]
rb_2016_sum = rb_2016_sum.sort_values(['Fantasy Points'], ascending=False)
rb_2016_sum.head(50)


342
Out[7]:
Name Rush Yds Rush TD Rec Yds Rec TD Fantasy Points
20 murray, demarco 1287 9 377 3 238.4
0 blount, legarrette 1192 18 0 0 227.2
18 mccoy, lesean 1267 13 0 0 204.7
10 ingram, mark 1043 6 319 4 196.2
7 gore, frank 1025 4 277 4 178.2
23 powell, bilal 722 3 388 2 141.0
30 stewart, jonathan 824 9 0 0 136.4
16 mathews, ryan 661 8 115 1 131.6
5 forte, matt 813 7 0 0 123.3
28 sproles, darren 438 2 427 2 110.5
9 hightower, tim 548 4 200 1 104.8
33 williams, deangelo 345 4 118 2 82.3
25 rodgers, jacquizz 560 2 98 0 77.8
11 ivory, chris 439 3 0 0 61.9
15 lewis, dion 324 1 117 1 56.1
14 kuhn, john 37 4 70 1 40.7
4 forsett, justin 291 1 0 0 35.1
8 harris, dujuan 138 0 115 1 31.3
32 vereen, shane 158 1 94 0 31.2
31 tolbert, mike 114 0 72 1 24.6
12 johnson, chris 95 1 0 0 15.5
1 bush, reggie -3 1 90 0 14.7
29 starks, james 145 0 0 0 14.5
27 spiller, cj 18 0 50 1 12.8
34 woodhead, danny 116 0 0 0 11.6
19 mcfadden, darren 87 0 17 0 10.4
2 charles, jamaal 40 1 0 0 10.0
22 peterson, adrian 72 0 8 0 8.0
3 felton, jerome 13 0 57 0 7.0
6 foster, arian 55 0 0 0 5.5
17 mccluster, dexter 2 0 36 0 3.8
13 jones, taiwan -8 0 43 0 3.5
21 peerman, cedric 15 0 0 0 1.5
26 sherman, anthony 0 0 14 0 1.4
24 ridley, stevan 7 0 0 0 0.7

In [10]:
rb_2016_sum.to_csv('rb_sanity.csv')
print('Done!')


Done!