In [328]:
import csv
import pandas as pd
input_file = open("Ozone0714-stats.csv")
ultimate_raw_data = pd.read_csv(input_file)
In [329]:
ultimate_raw_data
Out[329]:
Date/Time Tournamemnt Opponent Point Elapsed Seconds Line Our Score - End of Point Their Score - End of Point Event Type Action Passer ... Player 18 Player 19 Player 20 Player 21 Player 22 Player 23 Player 24 Player 25 Player 26 Player 27
0 2014-06-15 12:09 Cackalackee Pheonix 7 O 1 0 Offense Goal Wootie ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
1 2014-06-15 12:09 Cackalackee Pheonix 51 D 1 1 Defense Pull NaN ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
2 2014-06-15 12:09 Cackalackee Pheonix 51 D 1 1 Defense Goal NaN ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
3 2014-06-15 12:09 Cackalackee Pheonix 102 O 1 2 Offense Catch Wootie ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
4 2014-06-15 12:09 Cackalackee Pheonix 102 O 1 2 Offense Catch Sam ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
5 2014-06-15 12:09 Cackalackee Pheonix 102 O 1 2 Offense Catch AD ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
6 2014-06-15 12:09 Cackalackee Pheonix 102 O 1 2 Offense Catch Wootie ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
7 2014-06-15 12:09 Cackalackee Pheonix 102 O 1 2 Offense Catch Sam ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
8 2014-06-15 12:09 Cackalackee Pheonix 102 O 1 2 Offense Catch Haley ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
9 2014-06-15 12:09 Cackalackee Pheonix 102 O 1 2 Offense Throwaway Sam ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
10 2014-06-15 12:09 Cackalackee Pheonix 102 O 1 2 Defense Goal NaN ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
11 2014-06-15 12:09 Cackalackee Pheonix 39 O 2 2 Offense Catch Haley ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
12 2014-06-15 12:09 Cackalackee Pheonix 39 O 2 2 Offense Catch Wootie ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
13 2014-06-15 12:09 Cackalackee Pheonix 39 O 2 2 Offense Catch Meg ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
14 2014-06-15 12:09 Cackalackee Pheonix 39 O 2 2 Offense Catch Angela ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
15 2014-06-15 12:09 Cackalackee Pheonix 39 O 2 2 Offense Catch Wootie ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
16 2014-06-15 12:09 Cackalackee Pheonix 39 O 2 2 Offense Catch Meg ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
17 2014-06-15 12:09 Cackalackee Pheonix 39 O 2 2 Offense Goal Puppy ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
18 2014-06-15 12:09 Cackalackee Pheonix 99 D 2 3 Defense Pull NaN ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
19 2014-06-15 12:09 Cackalackee Pheonix 99 D 2 3 Defense D NaN ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
20 2014-06-15 12:09 Cackalackee Pheonix 99 D 2 3 Offense Throwaway Angela ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
21 2014-06-15 12:09 Cackalackee Pheonix 99 D 2 3 Defense Goal NaN ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
22 2014-06-15 12:09 Cackalackee Pheonix 33 O 3 3 Offense Catch Sam ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
23 2014-06-15 12:09 Cackalackee Pheonix 33 O 3 3 Offense Catch Wootie ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
24 2014-06-15 12:09 Cackalackee Pheonix 33 O 3 3 Offense Catch Puppy ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
25 2014-06-15 12:09 Cackalackee Pheonix 33 O 3 3 Offense Goal Wootie ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
26 2014-06-15 12:09 Cackalackee Pheonix 6 D 3 4 Defense Pull NaN ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
27 2014-06-15 12:09 Cackalackee Pheonix 6 D 3 4 Defense Goal NaN ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
28 2014-06-15 12:09 Cackalackee Pheonix 81 O 4 4 Offense Catch AD ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
29 2014-06-15 12:09 Cackalackee Pheonix 81 O 4 4 Offense Throwaway Angela ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
2217 2014-06-14 10:00 Cackalackee Jackwagon 131 O 13 6 Defense Throwaway NaN ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
2218 2014-06-14 10:00 Cackalackee Jackwagon 131 O 13 6 Offense Catch Angela ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
2219 2014-06-14 10:00 Cackalackee Jackwagon 131 O 13 6 Offense Goal Hewey ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
2220 2014-06-14 10:00 Cackalackee Jackwagon 45 D 14 6 Defense Pull NaN ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
2221 2014-06-14 10:00 Cackalackee Jackwagon 45 D 14 6 Defense Throwaway NaN ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
2222 2014-06-14 10:00 Cackalackee Jackwagon 45 D 14 6 Offense Catch Wootie ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
2223 2014-06-14 10:00 Cackalackee Jackwagon 45 D 14 6 Offense Catch Red ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
2224 2014-06-14 10:00 Cackalackee Jackwagon 45 D 14 6 Offense Catch Snow ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
2225 2014-06-14 10:00 Cackalackee Jackwagon 45 D 14 6 Offense Goal Sam ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
2226 2014-06-14 10:00 Cackalackee Jackwagon 48 D 14 7 Defense Pull NaN ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
2227 2014-06-14 10:00 Cackalackee Jackwagon 48 D 14 7 Defense Throwaway NaN ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
2228 2014-06-14 10:00 Cackalackee Jackwagon 48 D 14 7 Offense Throwaway Lina ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
2229 2014-06-14 10:00 Cackalackee Jackwagon 48 D 14 7 Defense Goal NaN ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
2230 2014-06-14 10:00 Cackalackee Jackwagon 171 O 15 7 Offense Throwaway Wootie ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
2231 2014-06-14 10:00 Cackalackee Jackwagon 171 O 15 7 Defense Throwaway NaN ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
2232 2014-06-14 10:00 Cackalackee Jackwagon 171 O 15 7 Offense Catch Wootie ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
2233 2014-06-14 10:00 Cackalackee Jackwagon 171 O 15 7 Offense Catch Turtle ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
2234 2014-06-14 10:00 Cackalackee Jackwagon 171 O 15 7 Offense Catch Angela ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
2235 2014-06-14 10:00 Cackalackee Jackwagon 171 O 15 7 Offense Throwaway Mira ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
2236 2014-06-14 10:00 Cackalackee Jackwagon 171 O 15 7 Defense Throwaway NaN ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
2237 2014-06-14 10:00 Cackalackee Jackwagon 171 O 15 7 Offense Catch Turtle ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
2238 2014-06-14 10:00 Cackalackee Jackwagon 171 O 15 7 Offense Catch Nubby ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
2239 2014-06-14 10:00 Cackalackee Jackwagon 171 O 15 7 Offense Catch Angela ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
2240 2014-06-14 10:00 Cackalackee Jackwagon 171 O 15 7 Offense Catch Nubby ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
2241 2014-06-14 10:00 Cackalackee Jackwagon 171 O 15 7 Offense Catch Turtle ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
2242 2014-06-14 10:00 Cackalackee Jackwagon 171 O 15 7 Offense Throwaway Angela ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
2243 2014-06-14 10:00 Cackalackee Jackwagon 171 O 15 7 Defense Throwaway NaN ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
2244 2014-06-14 10:00 Cackalackee Jackwagon 171 O 15 7 Offense Catch Wootie ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
2245 2014-06-14 10:00 Cackalackee Jackwagon 171 O 15 7 Offense Catch Angela ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
2246 2014-06-14 10:00 Cackalackee Jackwagon 171 O 15 7 Offense Goal Nubby ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN

2247 rows × 41 columns

In [330]:
del ultimate_raw_data["Date/Time"]
In [331]:
ultimate_raw_data.count()
Out[331]:
Tournamemnt                   2247
Opponent                      2247
Point Elapsed Seconds         2247
Line                          2247
Our Score - End of Point      2247
Their Score - End of Point    2247
Event Type                    2247
Action                        2247
Passer                        1746
Receiver                      1746
Defender                       501
Hang Time (secs)               140
Player 0                      2247
Player 1                      2247
Player 2                      2247
Player 3                      2246
Player 4                      2246
Player 5                      2246
Player 6                      2235
Player 7                         0
Player 8                         0
Player 9                         0
Player 10                        0
Player 11                        0
Player 12                        0
Player 13                        0
Player 14                        0
Player 15                        0
Player 16                        0
Player 17                        0
Player 18                        0
Player 19                        0
Player 20                        0
Player 21                        0
Player 22                        0
Player 23                        0
Player 24                        0
Player 25                        0
Player 26                        0
Player 27                        0
dtype: int64
In [332]:
for i in range(7,28):
    this_label = "Player "+str(i)
    del ultimate_raw_data[this_label]
In [333]:
ultimate_raw_data
Out[333]:
Tournamemnt Opponent Point Elapsed Seconds Line Our Score - End of Point Their Score - End of Point Event Type Action Passer Receiver Defender Hang Time (secs) Player 0 Player 1 Player 2 Player 3 Player 4 Player 5 Player 6
0 Cackalackee Pheonix 7 O 1 0 Offense Goal Wootie Meg NaN NaN Wootie Annie Meg NaN NaN NaN NaN
1 Cackalackee Pheonix 51 D 1 1 Defense Pull NaN NaN Angela 5.776 Angela Red Cate Nubby Sam Allee Paige
2 Cackalackee Pheonix 51 D 1 1 Defense Goal NaN NaN Anonymous NaN Angela Red Cate Nubby Sam Allee Paige
3 Cackalackee Pheonix 102 O 1 2 Offense Catch Wootie Sam NaN NaN Wootie AD Red Sam Haley Turtle Hewey
4 Cackalackee Pheonix 102 O 1 2 Offense Catch Sam AD NaN NaN Wootie AD Red Sam Haley Turtle Hewey
5 Cackalackee Pheonix 102 O 1 2 Offense Catch AD Wootie NaN NaN Wootie AD Red Sam Haley Turtle Hewey
6 Cackalackee Pheonix 102 O 1 2 Offense Catch Wootie Sam NaN NaN Wootie AD Red Sam Haley Turtle Hewey
7 Cackalackee Pheonix 102 O 1 2 Offense Catch Sam Haley NaN NaN Wootie AD Red Sam Haley Turtle Hewey
8 Cackalackee Pheonix 102 O 1 2 Offense Catch Haley Sam NaN NaN Wootie AD Red Sam Haley Turtle Hewey
9 Cackalackee Pheonix 102 O 1 2 Offense Throwaway Sam Anonymous NaN NaN Wootie AD Red Sam Haley Turtle Hewey
10 Cackalackee Pheonix 102 O 1 2 Defense Goal NaN NaN Anonymous NaN Wootie AD Red Sam Haley Turtle Hewey
11 Cackalackee Pheonix 39 O 2 2 Offense Catch Haley Wootie NaN NaN Wootie Puppy Angela Lina Phebe Meg Haley
12 Cackalackee Pheonix 39 O 2 2 Offense Catch Wootie Meg NaN NaN Wootie Puppy Angela Lina Phebe Meg Haley
13 Cackalackee Pheonix 39 O 2 2 Offense Catch Meg Angela NaN NaN Wootie Puppy Angela Lina Phebe Meg Haley
14 Cackalackee Pheonix 39 O 2 2 Offense Catch Angela Wootie NaN NaN Wootie Puppy Angela Lina Phebe Meg Haley
15 Cackalackee Pheonix 39 O 2 2 Offense Catch Wootie Meg NaN NaN Wootie Puppy Angela Lina Phebe Meg Haley
16 Cackalackee Pheonix 39 O 2 2 Offense Catch Meg Puppy NaN NaN Wootie Puppy Angela Lina Phebe Meg Haley
17 Cackalackee Pheonix 39 O 2 2 Offense Goal Puppy Lina NaN NaN Wootie Puppy Angela Lina Phebe Meg Haley
18 Cackalackee Pheonix 99 D 2 3 Defense Pull NaN NaN Angela 3.797 Angela AD Cate Snow Allee Kate Mira
19 Cackalackee Pheonix 99 D 2 3 Defense D NaN NaN Angela NaN Angela AD Cate Snow Allee Kate Mira
20 Cackalackee Pheonix 99 D 2 3 Offense Throwaway Angela Anonymous NaN NaN Angela AD Cate Snow Allee Kate Mira
21 Cackalackee Pheonix 99 D 2 3 Defense Goal NaN NaN Anonymous NaN Angela AD Cate Snow Allee Kate Mira
22 Cackalackee Pheonix 33 O 3 3 Offense Catch Sam Wootie NaN NaN Wootie Puppy Red Sam Turtle Mira Hewey
23 Cackalackee Pheonix 33 O 3 3 Offense Catch Wootie Puppy NaN NaN Wootie Puppy Red Sam Turtle Mira Hewey
24 Cackalackee Pheonix 33 O 3 3 Offense Catch Puppy Wootie NaN NaN Wootie Puppy Red Sam Turtle Mira Hewey
25 Cackalackee Pheonix 33 O 3 3 Offense Goal Wootie Mira NaN NaN Wootie Puppy Red Sam Turtle Mira Hewey
26 Cackalackee Pheonix 6 D 3 4 Defense Pull NaN NaN Red 4.908 Wootie Puppy Red Sam Turtle Mira Hewey
27 Cackalackee Pheonix 6 D 3 4 Defense Goal NaN NaN Anonymous NaN Wootie Puppy Red Sam Turtle Mira Hewey
28 Cackalackee Pheonix 81 O 4 4 Offense Catch AD Angela NaN NaN Angela AD Cate Nubby Allee Paige Kate
29 Cackalackee Pheonix 81 O 4 4 Offense Throwaway Angela Anonymous NaN NaN Angela AD Cate Nubby Allee Paige Kate
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
2217 Cackalackee Jackwagon 131 O 13 6 Defense Throwaway NaN NaN Anonymous NaN Angela Cate Nubby Paige Turtle Mira Hewey
2218 Cackalackee Jackwagon 131 O 13 6 Offense Catch Angela Hewey NaN NaN Angela Cate Nubby Paige Turtle Mira Hewey
2219 Cackalackee Jackwagon 131 O 13 6 Offense Goal Hewey Mira NaN NaN Angela Cate Nubby Paige Turtle Mira Hewey
2220 Cackalackee Jackwagon 45 D 14 6 Defense Pull NaN NaN Wootie 4.380 Wootie Red Snow Sam Kate Phebe Meg
2221 Cackalackee Jackwagon 45 D 14 6 Defense Throwaway NaN NaN Anonymous NaN Wootie Red Snow Sam Kate Phebe Meg
2222 Cackalackee Jackwagon 45 D 14 6 Offense Catch Wootie Red NaN NaN Wootie Red Snow Sam Kate Phebe Meg
2223 Cackalackee Jackwagon 45 D 14 6 Offense Catch Red Snow NaN NaN Wootie Red Snow Sam Kate Phebe Meg
2224 Cackalackee Jackwagon 45 D 14 6 Offense Catch Snow Sam NaN NaN Wootie Red Snow Sam Kate Phebe Meg
2225 Cackalackee Jackwagon 45 D 14 6 Offense Goal Sam Kate NaN NaN Wootie Red Snow Sam Kate Phebe Meg
2226 Cackalackee Jackwagon 48 D 14 7 Defense Pull NaN NaN Haley 3.247 Puppy AD Cate Allee Paige Lina Haley
2227 Cackalackee Jackwagon 48 D 14 7 Defense Throwaway NaN NaN Anonymous NaN Puppy AD Cate Allee Paige Lina Haley
2228 Cackalackee Jackwagon 48 D 14 7 Offense Throwaway Lina Anonymous NaN NaN Puppy AD Cate Allee Paige Lina Haley
2229 Cackalackee Jackwagon 48 D 14 7 Defense Goal NaN NaN Anonymous NaN Puppy AD Cate Allee Paige Lina Haley
2230 Cackalackee Jackwagon 171 O 15 7 Offense Throwaway Wootie Anonymous NaN NaN Wootie Angela Nubby Snow Meg Turtle Mira
2231 Cackalackee Jackwagon 171 O 15 7 Defense Throwaway NaN NaN Anonymous NaN Wootie Angela Nubby Snow Meg Turtle Mira
2232 Cackalackee Jackwagon 171 O 15 7 Offense Catch Wootie Turtle NaN NaN Wootie Angela Nubby Snow Meg Turtle Mira
2233 Cackalackee Jackwagon 171 O 15 7 Offense Catch Turtle Angela NaN NaN Wootie Angela Nubby Snow Meg Turtle Mira
2234 Cackalackee Jackwagon 171 O 15 7 Offense Catch Angela Mira NaN NaN Wootie Angela Nubby Snow Meg Turtle Mira
2235 Cackalackee Jackwagon 171 O 15 7 Offense Throwaway Mira Anonymous NaN NaN Wootie Angela Nubby Snow Meg Turtle Mira
2236 Cackalackee Jackwagon 171 O 15 7 Defense Throwaway NaN NaN Anonymous NaN Wootie Angela Nubby Snow Meg Turtle Mira
2237 Cackalackee Jackwagon 171 O 15 7 Offense Catch Turtle Nubby NaN NaN Wootie Angela Nubby Snow Meg Turtle Mira
2238 Cackalackee Jackwagon 171 O 15 7 Offense Catch Nubby Angela NaN NaN Wootie Angela Nubby Snow Meg Turtle Mira
2239 Cackalackee Jackwagon 171 O 15 7 Offense Catch Angela Nubby NaN NaN Wootie Angela Nubby Snow Meg Turtle Mira
2240 Cackalackee Jackwagon 171 O 15 7 Offense Catch Nubby Turtle NaN NaN Wootie Angela Nubby Snow Meg Turtle Mira
2241 Cackalackee Jackwagon 171 O 15 7 Offense Catch Turtle Angela NaN NaN Wootie Angela Nubby Snow Meg Turtle Mira
2242 Cackalackee Jackwagon 171 O 15 7 Offense Throwaway Angela Anonymous NaN NaN Wootie Angela Nubby Snow Meg Turtle Mira
2243 Cackalackee Jackwagon 171 O 15 7 Defense Throwaway NaN NaN Anonymous NaN Wootie Angela Nubby Snow Meg Turtle Mira
2244 Cackalackee Jackwagon 171 O 15 7 Offense Catch Wootie Angela NaN NaN Wootie Angela Nubby Snow Meg Turtle Mira
2245 Cackalackee Jackwagon 171 O 15 7 Offense Catch Angela Nubby NaN NaN Wootie Angela Nubby Snow Meg Turtle Mira
2246 Cackalackee Jackwagon 171 O 15 7 Offense Goal Nubby Mira NaN NaN Wootie Angela Nubby Snow Meg Turtle Mira

2247 rows × 19 columns

In [334]:
ultimate_raw_data.count()
Out[334]:
Tournamemnt                   2247
Opponent                      2247
Point Elapsed Seconds         2247
Line                          2247
Our Score - End of Point      2247
Their Score - End of Point    2247
Event Type                    2247
Action                        2247
Passer                        1746
Receiver                      1746
Defender                       501
Hang Time (secs)               140
Player 0                      2247
Player 1                      2247
Player 2                      2247
Player 3                      2246
Player 4                      2246
Player 5                      2246
Player 6                      2235
dtype: int64
In [335]:
this_gb = ultimate_raw_data.groupby('Action')
this_gb_size = this_gb.size()
print(this_gb_size)
type(this_gb_size)
this_gb_size.plot(kind = "bar", title = "Action")
Action
Catch        1395
D              93
Drop           25
Goal          280
Pull          151
PullOb          3
Throwaway     300
dtype: int64
Out[335]:
<matplotlib.axes.AxesSubplot at 0x10bb21390>
In [336]:
column_name_list = list(ultimate_raw_data.columns)
print len(column_name_list)
column_name_list
19
Out[336]:
['Tournamemnt',
 'Opponent',
 'Point Elapsed Seconds',
 'Line',
 'Our Score - End of Point',
 'Their Score - End of Point',
 'Event Type',
 'Action',
 'Passer',
 'Receiver',
 'Defender',
 'Hang Time (secs)',
 'Player 0',
 'Player 1',
 'Player 2',
 'Player 3',
 'Player 4',
 'Player 5',
 'Player 6']
In [337]:
def make_bar_chart(i):
    column_name = column_name_list[i]
    this_gb = ultimate_raw_data.groupby(column_name)
    this_gb_size = this_gb.size()
    type(this_gb_size)
    this_gb_size.plot(kind = "bar", title = column_name)
In [338]:
make_bar_chart(9)
In [339]:
try1 = ultimate_raw_data.groupby(['Opponent', 'Action'])
try1.size().plot(kind = "bar", title = 'Opponent then Action', figsize = (18, 8))
Out[339]:
<matplotlib.axes.AxesSubplot at 0x1116a9d10>
In [340]:
def make_double_bar_chart(i, j):
    firstname = column_name_list[i]
    secondname = column_name_list[j]
    try1 = ultimate_raw_data.groupby([firstname, secondname])
    try1.size().plot(kind = "bar", title = firstname+' then '+secondname, figsize = (18, 8))
In [341]:
#make_double_bar_chart(6, 8)
make_double_bar_chart(7,8)
In [342]:
ultimate_raw_data['Shifted Their Score']=ultimate_raw_data['Their Score - End of Point'].shift(1)
ultimate_raw_data['Shifted Our Score']=ultimate_raw_data['Our Score - End of Point'].shift(1)
In [343]:
ultimate_raw_data[['Our Score - End of Point', 'Shifted Our Score']]
Out[343]:
Our Score - End of Point Shifted Our Score
0 1 NaN
1 1 1
2 1 1
3 1 1
4 1 1
5 1 1
6 1 1
7 1 1
8 1 1
9 1 1
10 1 1
11 2 1
12 2 2
13 2 2
14 2 2
15 2 2
16 2 2
17 2 2
18 2 2
19 2 2
20 2 2
21 2 2
22 3 2
23 3 3
24 3 3
25 3 3
26 3 3
27 3 3
28 4 3
29 4 4
... ... ...
2217 13 13
2218 13 13
2219 13 13
2220 14 13
2221 14 14
2222 14 14
2223 14 14
2224 14 14
2225 14 14
2226 14 14
2227 14 14
2228 14 14
2229 14 14
2230 15 14
2231 15 15
2232 15 15
2233 15 15
2234 15 15
2235 15 15
2236 15 15
2237 15 15
2238 15 15
2239 15 15
2240 15 15
2241 15 15
2242 15 15
2243 15 15
2244 15 15
2245 15 15
2246 15 15

2247 rows × 2 columns

In [344]:
ultimate_raw_data['diff in our score'] = ultimate_raw_data['Our Score - End of Point'] - \
    ultimate_raw_data['Shifted Our Score']
ultimate_raw_data['diff in their score'] = ultimate_raw_data['Their Score - End of Point'] - \
    ultimate_raw_data['Shifted Their Score']
In [345]:
ultimate_raw_data.count()
Out[345]:
Tournamemnt                   2247
Opponent                      2247
Point Elapsed Seconds         2247
Line                          2247
Our Score - End of Point      2247
Their Score - End of Point    2247
Event Type                    2247
Action                        2247
Passer                        1746
Receiver                      1746
Defender                       501
Hang Time (secs)               140
Player 0                      2247
Player 1                      2247
Player 2                      2247
Player 3                      2246
Player 4                      2246
Player 5                      2246
Player 6                      2235
Shifted Their Score           2246
Shifted Our Score             2246
diff in our score             2246
diff in their score           2246
dtype: int64
In [346]:
score_change_series = (ultimate_raw_data['diff in our score'] != 0) | (ultimate_raw_data['diff in their score'] != 0)
In [347]:
point_data = ultimate_raw_data[score_change_series]
In [348]:
point_data.count()
Out[348]:
Tournamemnt                   280
Opponent                      280
Point Elapsed Seconds         280
Line                          280
Our Score - End of Point      280
Their Score - End of Point    280
Event Type                    280
Action                        280
Passer                        127
Receiver                      127
Defender                      153
Hang Time (secs)              139
Player 0                      280
Player 1                      280
Player 2                      280
Player 3                      279
Player 4                      279
Player 5                      279
Player 6                      277
Shifted Their Score           279
Shifted Our Score             279
diff in our score             279
diff in their score           279
dtype: int64
In [349]:
point_data
Out[349]:
Tournamemnt Opponent Point Elapsed Seconds Line Our Score - End of Point Their Score - End of Point Event Type Action Passer Receiver ... Player 1 Player 2 Player 3 Player 4 Player 5 Player 6 Shifted Their Score Shifted Our Score diff in our score diff in their score
0 Cackalackee Pheonix 7 O 1 0 Offense Goal Wootie Meg ... Annie Meg NaN NaN NaN NaN NaN NaN NaN NaN
1 Cackalackee Pheonix 51 D 1 1 Defense Pull NaN NaN ... Red Cate Nubby Sam Allee Paige 0 1 0 1
3 Cackalackee Pheonix 102 O 1 2 Offense Catch Wootie Sam ... AD Red Sam Haley Turtle Hewey 1 1 0 1
11 Cackalackee Pheonix 39 O 2 2 Offense Catch Haley Wootie ... Puppy Angela Lina Phebe Meg Haley 2 1 1 0
18 Cackalackee Pheonix 99 D 2 3 Defense Pull NaN NaN ... AD Cate Snow Allee Kate Mira 2 2 0 1
22 Cackalackee Pheonix 33 O 3 3 Offense Catch Sam Wootie ... Puppy Red Sam Turtle Mira Hewey 3 2 1 0
26 Cackalackee Pheonix 6 D 3 4 Defense Pull NaN NaN ... Puppy Red Sam Turtle Mira Hewey 3 3 0 1
28 Cackalackee Pheonix 81 O 4 4 Offense Catch AD Angela ... AD Cate Nubby Allee Paige Kate 4 3 1 0
40 Cackalackee Pheonix 36 D 4 5 Defense Pull NaN NaN ... Red Cate Snow Allee Meg Haley 4 4 0 1
42 Cackalackee Pheonix 37 O 5 5 Offense Catch Angela Haley ... Puppy Angela Sam Phebe Haley Turtle 5 4 1 0
48 Cackalackee Pheonix 42 D 5 6 Defense Pull NaN NaN ... Angela Red Nubby Lina Phebe Meg 5 5 0 1
50 Cackalackee Pheonix 57 O 6 6 Offense Catch Haley AD ... Red Cate Allee Haley Mira Hewey 6 5 1 0
58 Cackalackee Pheonix 27 D 6 7 Defense Pull NaN NaN ... Angela Cate Snow Meg Haley Hewey 6 6 0 1
60 Cackalackee Pheonix 102 O 7 7 Offense Catch Sam AD ... Angela AD Sam Paige Kate Turtle 7 6 1 0
68 Cackalackee Pheonix 54 D 7 8 Defense Pull NaN NaN ... AD Snow Sam Haley Turtle Mira 7 7 0 1
70 Cackalackee Pheonix 154 D 8 8 Defense Pull NaN NaN ... AD Red Cate Allee Mira Hewey 8 7 1 0
82 Cackalackee Pheonix 44 D 8 9 Defense Pull NaN NaN ... Angela Cate Sam Kate Meg Mira 8 8 0 1
84 Cackalackee Pheonix 36 O 9 9 Offense Catch AD Wootie ... AD Nubby Snow Allee Haley Turtle 9 8 1 0
91 Cackalackee Pheonix 59 D 10 9 Defense Pull NaN NaN ... Red Sam Paige Meg Mira Hewey 9 9 1 0
98 Cackalackee Pheonix 385 D 11 9 Defense Pull NaN NaN ... Red Cate Nubby Allee Kate Mira 9 10 1 0
114 Cackalackee Pheonix 90 D 12 9 Defense Pull NaN NaN ... Red Cate Meg Haley Turtle Hewey 9 11 1 0
119 Cackalackee Pheonix 79 D 13 9 Defense Pull NaN NaN ... Puppy Sam Allee Kate Haley Mira 9 12 1 0
131 Cackalackee Pheonix 55 D 14 9 Defense Pull NaN NaN ... AD Red Cate Allee Kate Turtle 9 13 1 0
139 Cackalackee Pheonix 80 D 15 9 Defense Pull NaN NaN ... Angela AD Snow Sam Phebe Hewey 9 14 1 0
145 Chesapeake Nightlock 45 O 1 0 Offense Catch Annie Cate ... Red Cate Kate Annie Meg Mira 9 15 -14 -9
151 Chesapeake Nightlock 147 D 1 1 Defense Pull NaN NaN ... Angela Nubby Annie Haley Turtle Hewey 0 1 0 1
156 Chesapeake Nightlock 42 O 2 1 Offense Catch AD Red ... Alicia Angela AD Red Sam Kate 1 1 1 0
164 Chesapeake Nightlock 82 D 3 1 Defense Pull NaN NaN ... Angela Annie Haley Turtle Mira Hewey 1 2 1 0
177 Chesapeake Nightlock 88 D 3 2 Defense Pull NaN NaN ... AD Red Cate Paige Annie Meg 1 3 0 1
185 Chesapeake Nightlock 70 O 3 3 Offense Catch Angela Wootie ... Alicia Angela Nubby Sam Meg Mira 2 3 0 1
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
1985 Chesapeake Hot Metal 186 D 7 4 Defense Pull NaN NaN ... AD Sam Paige Kate Meg Turtle 4 6 1 0
1998 Chesapeake Hot Metal 32 D 8 4 Defense Pull NaN NaN ... Puppy Alicia Cate Sam Haley Hewey 4 7 1 0
2002 Chesapeake Hot Metal 177 D 9 4 Defense Pull NaN NaN ... Angela Nubby Paige Lina Annie Turtle 4 8 1 0
2018 Chesapeake Hot Metal 62 D 10 4 Defense Pull NaN NaN ... Sam Kate Annie Phebe Haley Mira 4 9 1 0
2029 Chesapeake Hot Metal 105 D 11 4 Defense PullOb NaN NaN ... Angela Red Cate Nubby Sam Meg 4 10 1 0
2039 Chesapeake Hot Metal 137 D 12 4 Defense Pull NaN NaN ... AD Red Cate Kate Mira Hewey 4 11 1 0
2049 Chesapeake Hot Metal 32 D 12 5 Defense Pull NaN NaN ... Angela Nubby Sam Paige Lina Annie 4 12 0 1
2051 Chesapeake Hot Metal 67 O 13 5 Offense Catch AD Angela ... Angela AD Cate Lina Haley Turtle 5 12 1 0
2064 Cackalackee Jackwagon 72 D 1 0 Defense Pull NaN NaN ... Cate Meg Haley Turtle Mira Hewey 5 13 -12 -5
2071 Cackalackee Jackwagon 29 D 2 0 Defense Pull NaN NaN ... Puppy Angela Sam Allee Paige Kate 0 1 1 0
2075 Cackalackee Jackwagon 24 D 3 0 Defense Pull NaN NaN ... Red Snow Allee Phebe Haley Mira 0 2 1 0
2080 Cackalackee Jackwagon 410 D 4 0 Defense Pull NaN NaN ... Cate Nubby Snow Lina Meg Turtle 0 3 1 0
2104 Cackalackee Jackwagon 47 D 4 1 Defense Pull NaN NaN ... Puppy Red Sam Paige Lina Kate 0 4 0 1
2108 Cackalackee Jackwagon 127 O 4 2 Offense Catch Haley Angela ... Snow Allee Phebe Haley Mira Hewey 1 4 0 1
2119 Cackalackee Jackwagon 40 O 5 2 Offense Catch AD Cate ... Red Cate Snow Meg Turtle Hewey 2 4 1 0
2128 Cackalackee Jackwagon 34 D 5 3 Defense Pull NaN NaN ... Puppy Angela Paige Lina Kate Haley 2 5 0 1
2130 Cackalackee Jackwagon 61 O 6 3 Offense Catch Wootie Sam ... Cate Nubby Sam Allee Mira Hewey 3 5 1 0
2143 Cackalackee Jackwagon 117 D 6 4 Defense Pull NaN NaN ... AD Red Snow Paige Phebe Turtle 3 6 0 1
2148 Cackalackee Jackwagon 54 O 7 4 Offense Catch AD Wootie ... AD Sam Kate Meg Haley Turtle 4 6 1 0
2153 Cackalackee Jackwagon 42 D 7 5 Defense Pull NaN NaN ... Angela Cate Nubby Allee Lina Mira 4 7 0 1
2155 Cackalackee Jackwagon 83 O 8 5 Offense Throwaway Wootie Anonymous ... AD Red Sam Kate Phebe Hewey 5 7 1 0
2159 Cackalackee Jackwagon 30 O 9 5 Offense Catch Haley Paige ... Angela Nubby Snow Paige Meg Haley 5 8 1 0
2163 Cackalackee Jackwagon 96 D 10 5 Defense Pull NaN NaN ... AD Sam Allee Lina Turtle Mira 5 9 1 0
2173 Cackalackee Jackwagon 53 D 11 5 Defense Pull NaN NaN ... Red Cate Allee Paige Phebe Hewey 5 10 1 0
2177 Cackalackee Jackwagon 97 D 12 5 Defense Pull NaN NaN ... Nubby Snow Sam Kate Meg Haley 5 11 1 0
2187 Cackalackee Jackwagon 318 D 12 6 Defense Pull NaN NaN ... AD Red Sam Lina Phebe Haley 5 12 0 1
2203 Cackalackee Jackwagon 131 O 13 6 Offense Catch Nubby Angela ... Cate Nubby Paige Turtle Mira Hewey 6 12 1 0
2220 Cackalackee Jackwagon 45 D 14 6 Defense Pull NaN NaN ... Red Snow Sam Kate Phebe Meg 6 13 1 0
2226 Cackalackee Jackwagon 48 D 14 7 Defense Pull NaN NaN ... AD Cate Allee Paige Lina Haley 6 14 0 1
2230 Cackalackee Jackwagon 171 O 15 7 Offense Throwaway Wootie Anonymous ... Angela Nubby Snow Meg Turtle Mira 7 14 1 0

280 rows × 23 columns

In [350]:
opp_gb = point_data.groupby('Opponent')
opp_gb.size().plot(kind = "bar", title = 'Opponent', figsize = (18, 8))
Out[350]:
<matplotlib.axes.AxesSubplot at 0x1116a9350>
In [351]:
opp_diff = point_data.groupby(['Action', 'Passer'])
print type(opp_diff.size())
opp_diff.size().plot(kind = "bar", title = 'Action then Passer', figsize = (18, 8))
<class 'pandas.core.series.Series'>
Out[351]:
<matplotlib.axes.AxesSubplot at 0x1116b2b10>
In [352]:
player_set = set([])
label_list = []
for i in range(0, 7):
    label = "Player "+str(i)
    label_list.append(label)
    player_set = player_set.union(set(point_data[label]))
    __
print player_set
set([nan, 'AD', 'Snow', 'Angela', 'Phebe', 'Hewey', 'Annie', 'Wootie', 'Puppy', 'Red', 'Cate', 'Turtle', 'Nubby', 'Meg', 'Paige', 'Sam', 'Alicia', 'Haley', 'Mira', 'Allee', 'Kate', 'Lina'])
In [353]:
if nan in player_set: player_set.remove(nan)
player_set
Out[353]:
{'AD',
 'Alicia',
 'Allee',
 'Angela',
 'Annie',
 'Cate',
 'Haley',
 'Hewey',
 'Kate',
 'Lina',
 'Meg',
 'Mira',
 'Nubby',
 'Paige',
 'Phebe',
 'Puppy',
 'Red',
 'Sam',
 'Snow',
 'Turtle',
 'Wootie'}
In [379]:
players_df = point_data[label_list]
for player in player_set:
    print player
    this_player_boolean_df = players_df.isin([player])
    this_player_boolean = this_player_boolean_df['Player 0'] | \
        this_player_boolean_df['Player 1'] | this_player_boolean_df['Player 2'] | \
        this_player_boolean_df['Player 3'] | this_player_boolean_df['Player 4'] | \
        this_player_boolean_df['Player 5'] | this_player_boolean_df['Player 6']
    point_data[player] = this_player_boolean.astype(float)
AD
Snow
Angela
Phebe
Hewey
Annie
Wootie
Puppy
Red
Cate
Turtle
Nubby
Meg
Paige
Sam
Alicia
Haley
Mira
Allee
Kate
Lina
In [380]:
point_data
Out[380]:
Tournamemnt Opponent Point Elapsed Seconds Line Our Score - End of Point Their Score - End of Point Event Type Action Passer Receiver ... Paige Sam Alicia Haley Mira Allee Kate Lina we scored Score
0 Cackalackee Pheonix 7 O 1 0 Offense Goal Wootie Meg ... 0 0 0 0 0 0 0 0 1 1
1 Cackalackee Pheonix 51 D 1 1 Defense Pull NaN NaN ... 1 1 0 0 0 1 0 0 0 0
3 Cackalackee Pheonix 102 O 1 2 Offense Catch Wootie Sam ... 0 1 0 1 0 0 0 0 0 0
11 Cackalackee Pheonix 39 O 2 2 Offense Catch Haley Wootie ... 0 0 0 1 0 0 0 1 1 1
18 Cackalackee Pheonix 99 D 2 3 Defense Pull NaN NaN ... 0 0 0 0 1 1 1 0 0 0
22 Cackalackee Pheonix 33 O 3 3 Offense Catch Sam Wootie ... 0 1 0 0 1 0 0 0 1 1
26 Cackalackee Pheonix 6 D 3 4 Defense Pull NaN NaN ... 0 1 0 0 1 0 0 0 0 0
28 Cackalackee Pheonix 81 O 4 4 Offense Catch AD Angela ... 1 0 0 0 0 1 1 0 1 1
40 Cackalackee Pheonix 36 D 4 5 Defense Pull NaN NaN ... 0 0 0 1 0 1 0 0 0 0
42 Cackalackee Pheonix 37 O 5 5 Offense Catch Angela Haley ... 0 1 0 1 0 0 0 0 1 1
48 Cackalackee Pheonix 42 D 5 6 Defense Pull NaN NaN ... 0 0 0 0 0 0 0 1 0 0
50 Cackalackee Pheonix 57 O 6 6 Offense Catch Haley AD ... 0 0 0 1 1 1 0 0 1 1
58 Cackalackee Pheonix 27 D 6 7 Defense Pull NaN NaN ... 0 0 0 1 0 0 0 0 0 0
60 Cackalackee Pheonix 102 O 7 7 Offense Catch Sam AD ... 1 1 0 0 0 0 1 0 1 1
68 Cackalackee Pheonix 54 D 7 8 Defense Pull NaN NaN ... 0 1 0 1 1 0 0 0 0 0
70 Cackalackee Pheonix 154 D 8 8 Defense Pull NaN NaN ... 0 0 0 0 1 1 0 0 1 1
82 Cackalackee Pheonix 44 D 8 9 Defense Pull NaN NaN ... 0 1 0 0 1 0 1 0 0 0
84 Cackalackee Pheonix 36 O 9 9 Offense Catch AD Wootie ... 0 0 0 1 0 1 0 0 1 1
91 Cackalackee Pheonix 59 D 10 9 Defense Pull NaN NaN ... 1 1 0 0 1 0 0 0 1 1
98 Cackalackee Pheonix 385 D 11 9 Defense Pull NaN NaN ... 0 0 0 0 1 1 1 0 1 1
114 Cackalackee Pheonix 90 D 12 9 Defense Pull NaN NaN ... 0 0 0 1 0 0 0 0 1 1
119 Cackalackee Pheonix 79 D 13 9 Defense Pull NaN NaN ... 0 1 0 1 1 1 1 0 1 1
131 Cackalackee Pheonix 55 D 14 9 Defense Pull NaN NaN ... 0 0 0 0 0 1 1 0 1 1
139 Cackalackee Pheonix 80 D 15 9 Defense Pull NaN NaN ... 0 1 0 0 0 0 0 0 1 1
145 Chesapeake Nightlock 45 O 1 0 Offense Catch Annie Cate ... 0 0 0 0 1 0 1 0 1 1
151 Chesapeake Nightlock 147 D 1 1 Defense Pull NaN NaN ... 0 0 0 1 0 0 0 0 0 0
156 Chesapeake Nightlock 42 O 2 1 Offense Catch AD Red ... 0 1 1 0 0 0 1 0 1 1
164 Chesapeake Nightlock 82 D 3 1 Defense Pull NaN NaN ... 0 0 0 1 1 0 0 0 1 1
177 Chesapeake Nightlock 88 D 3 2 Defense Pull NaN NaN ... 1 0 0 0 0 0 0 0 0 0
185 Chesapeake Nightlock 70 O 3 3 Offense Catch Angela Wootie ... 0 1 1 0 1 0 0 0 0 0
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
1985 Chesapeake Hot Metal 186 D 7 4 Defense Pull NaN NaN ... 1 1 0 0 0 0 1 0 1 1
1998 Chesapeake Hot Metal 32 D 8 4 Defense Pull NaN NaN ... 0 1 1 1 0 0 0 0 1 1
2002 Chesapeake Hot Metal 177 D 9 4 Defense Pull NaN NaN ... 1 0 0 0 0 0 0 1 1 1
2018 Chesapeake Hot Metal 62 D 10 4 Defense Pull NaN NaN ... 0 1 0 1 1 0 1 0 1 1
2029 Chesapeake Hot Metal 105 D 11 4 Defense PullOb NaN NaN ... 0 1 0 0 0 0 0 0 1 1
2039 Chesapeake Hot Metal 137 D 12 4 Defense Pull NaN NaN ... 0 0 0 0 1 0 1 0 1 1
2049 Chesapeake Hot Metal 32 D 12 5 Defense Pull NaN NaN ... 1 1 1 0 0 0 0 1 0 0
2051 Chesapeake Hot Metal 67 O 13 5 Offense Catch AD Angela ... 0 0 0 1 0 0 0 1 1 1
2064 Cackalackee Jackwagon 72 D 1 0 Defense Pull NaN NaN ... 0 0 0 1 1 0 0 0 1 1
2071 Cackalackee Jackwagon 29 D 2 0 Defense Pull NaN NaN ... 1 1 0 0 0 1 1 0 1 1
2075 Cackalackee Jackwagon 24 D 3 0 Defense Pull NaN NaN ... 0 0 0 1 1 1 0 0 1 1
2080 Cackalackee Jackwagon 410 D 4 0 Defense Pull NaN NaN ... 0 0 0 0 0 0 0 1 1 1
2104 Cackalackee Jackwagon 47 D 4 1 Defense Pull NaN NaN ... 1 1 0 0 0 0 1 1 0 0
2108 Cackalackee Jackwagon 127 O 4 2 Offense Catch Haley Angela ... 0 0 0 1 1 1 0 0 0 0
2119 Cackalackee Jackwagon 40 O 5 2 Offense Catch AD Cate ... 0 0 0 0 0 0 0 0 1 1
2128 Cackalackee Jackwagon 34 D 5 3 Defense Pull NaN NaN ... 1 0 0 1 0 0 1 1 0 0
2130 Cackalackee Jackwagon 61 O 6 3 Offense Catch Wootie Sam ... 0 1 0 0 1 1 0 0 1 1
2143 Cackalackee Jackwagon 117 D 6 4 Defense Pull NaN NaN ... 1 0 0 0 0 0 0 0 0 0
2148 Cackalackee Jackwagon 54 O 7 4 Offense Catch AD Wootie ... 0 1 0 1 0 0 1 0 1 1
2153 Cackalackee Jackwagon 42 D 7 5 Defense Pull NaN NaN ... 0 0 0 0 1 1 0 1 0 0
2155 Cackalackee Jackwagon 83 O 8 5 Offense Throwaway Wootie Anonymous ... 0 1 0 0 0 0 1 0 1 1
2159 Cackalackee Jackwagon 30 O 9 5 Offense Catch Haley Paige ... 1 0 0 1 0 0 0 0 1 1
2163 Cackalackee Jackwagon 96 D 10 5 Defense Pull NaN NaN ... 0 1 0 0 1 1 0 1 1 1
2173 Cackalackee Jackwagon 53 D 11 5 Defense Pull NaN NaN ... 1 0 0 0 0 1 0 0 1 1
2177 Cackalackee Jackwagon 97 D 12 5 Defense Pull NaN NaN ... 0 1 0 1 0 0 1 0 1 1
2187 Cackalackee Jackwagon 318 D 12 6 Defense Pull NaN NaN ... 0 1 0 1 0 0 0 1 0 0
2203 Cackalackee Jackwagon 131 O 13 6 Offense Catch Nubby Angela ... 1 0 0 0 1 0 0 0 1 1
2220 Cackalackee Jackwagon 45 D 14 6 Defense Pull NaN NaN ... 0 1 0 0 0 0 1 0 1 1
2226 Cackalackee Jackwagon 48 D 14 7 Defense Pull NaN NaN ... 1 0 0 1 0 1 0 1 0 0
2230 Cackalackee Jackwagon 171 O 15 7 Offense Throwaway Wootie Anonymous ... 0 0 0 0 1 0 0 0 1 1

280 rows × 46 columns

In [381]:
diff_our_score = point_data['diff in our score']
plot(diff_our_score)
Out[381]:
[<matplotlib.lines.Line2D at 0x1120002d0>]
In [382]:
print diff_our_score.index
Int64Index([0, 1, 3, 11, 18, 22, 26, 28, 40, 42, 48, 50, 58, 60, 68, 70, 82, 84, 91, 98, 114, 119, 131, 139, 145, 151, 156, 164, 177, 185, 190, 206, 208, 216, 223, 225, 246, 248, 253, 266, 269, 281, 287, 300, 304, 310, 319, 321, 328, 330, 336, 338, 340, 350, 354, 356, 362, 373, 382, 384, 399, 400, 402, 414, 418, 422, 424, 431, 433, 470, 478, 490, 492, 496, 499, 507, 512, 518, 520, 523, 526, 533, 544, 550, 554, 562, 572, 574, 580, 582, 591, 593, 601, 603, 607, 614, 624, 653, 661, 671, ...], dtype='int64')
In [383]:
point_data['Our Score - End of Point'][0]
Out[383]:
1
In [384]:
we_scored_series = pd.Series([])
for i in diff_our_score.index:
    if float(diff_our_score[i]) not in [0.0, 1.0]:
        we_scored_series[i] = point_data.loc[i,'Our Score - End of Point']
    else:
        we_scored_series[i] = diff_our_score[i]
In [385]:
point_data['Score'] = we_scored_series
-c:1: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_index,col_indexer] = value instead
In [386]:
point_data[['Our Score - End of Point','diff in our score', 'Score']]
Out[386]:
Our Score - End of Point diff in our score Score
0 1 NaN 1
1 1 0 0
3 1 0 0
11 2 1 1
18 2 0 0
22 3 1 1
26 3 0 0
28 4 1 1
40 4 0 0
42 5 1 1
48 5 0 0
50 6 1 1
58 6 0 0
60 7 1 1
68 7 0 0
70 8 1 1
82 8 0 0
84 9 1 1
91 10 1 1
98 11 1 1
114 12 1 1
119 13 1 1
131 14 1 1
139 15 1 1
145 1 -14 1
151 1 0 0
156 2 1 1
164 3 1 1
177 3 0 0
185 3 0 0
... ... ... ...
1985 7 1 1
1998 8 1 1
2002 9 1 1
2018 10 1 1
2029 11 1 1
2039 12 1 1
2049 12 0 0
2051 13 1 1
2064 1 -12 1
2071 2 1 1
2075 3 1 1
2080 4 1 1
2104 4 0 0
2108 4 0 0
2119 5 1 1
2128 5 0 0
2130 6 1 1
2143 6 0 0
2148 7 1 1
2153 7 0 0
2155 8 1 1
2159 9 1 1
2163 10 1 1
2173 11 1 1
2177 12 1 1
2187 12 0 0
2203 13 1 1
2220 14 1 1
2226 14 0 0
2230 15 1 1

280 rows × 3 columns

In [387]:
point_data
Out[387]:
Tournamemnt Opponent Point Elapsed Seconds Line Our Score - End of Point Their Score - End of Point Event Type Action Passer Receiver ... Paige Sam Alicia Haley Mira Allee Kate Lina we scored Score
0 Cackalackee Pheonix 7 O 1 0 Offense Goal Wootie Meg ... 0 0 0 0 0 0 0 0 1 1
1 Cackalackee Pheonix 51 D 1 1 Defense Pull NaN NaN ... 1 1 0 0 0 1 0 0 0 0
3 Cackalackee Pheonix 102 O 1 2 Offense Catch Wootie Sam ... 0 1 0 1 0 0 0 0 0 0
11 Cackalackee Pheonix 39 O 2 2 Offense Catch Haley Wootie ... 0 0 0 1 0 0 0 1 1 1
18 Cackalackee Pheonix 99 D 2 3 Defense Pull NaN NaN ... 0 0 0 0 1 1 1 0 0 0
22 Cackalackee Pheonix 33 O 3 3 Offense Catch Sam Wootie ... 0 1 0 0 1 0 0 0 1 1
26 Cackalackee Pheonix 6 D 3 4 Defense Pull NaN NaN ... 0 1 0 0 1 0 0 0 0 0
28 Cackalackee Pheonix 81 O 4 4 Offense Catch AD Angela ... 1 0 0 0 0 1 1 0 1 1
40 Cackalackee Pheonix 36 D 4 5 Defense Pull NaN NaN ... 0 0 0 1 0 1 0 0 0 0
42 Cackalackee Pheonix 37 O 5 5 Offense Catch Angela Haley ... 0 1 0 1 0 0 0 0 1 1
48 Cackalackee Pheonix 42 D 5 6 Defense Pull NaN NaN ... 0 0 0 0 0 0 0 1 0 0
50 Cackalackee Pheonix 57 O 6 6 Offense Catch Haley AD ... 0 0 0 1 1 1 0 0 1 1
58 Cackalackee Pheonix 27 D 6 7 Defense Pull NaN NaN ... 0 0 0 1 0 0 0 0 0 0
60 Cackalackee Pheonix 102 O 7 7 Offense Catch Sam AD ... 1 1 0 0 0 0 1 0 1 1
68 Cackalackee Pheonix 54 D 7 8 Defense Pull NaN NaN ... 0 1 0 1 1 0 0 0 0 0
70 Cackalackee Pheonix 154 D 8 8 Defense Pull NaN NaN ... 0 0 0 0 1 1 0 0 1 1
82 Cackalackee Pheonix 44 D 8 9 Defense Pull NaN NaN ... 0 1 0 0 1 0 1 0 0 0
84 Cackalackee Pheonix 36 O 9 9 Offense Catch AD Wootie ... 0 0 0 1 0 1 0 0 1 1
91 Cackalackee Pheonix 59 D 10 9 Defense Pull NaN NaN ... 1 1 0 0 1 0 0 0 1 1
98 Cackalackee Pheonix 385 D 11 9 Defense Pull NaN NaN ... 0 0 0 0 1 1 1 0 1 1
114 Cackalackee Pheonix 90 D 12 9 Defense Pull NaN NaN ... 0 0 0 1 0 0 0 0 1 1
119 Cackalackee Pheonix 79 D 13 9 Defense Pull NaN NaN ... 0 1 0 1 1 1 1 0 1 1
131 Cackalackee Pheonix 55 D 14 9 Defense Pull NaN NaN ... 0 0 0 0 0 1 1 0 1 1
139 Cackalackee Pheonix 80 D 15 9 Defense Pull NaN NaN ... 0 1 0 0 0 0 0 0 1 1
145 Chesapeake Nightlock 45 O 1 0 Offense Catch Annie Cate ... 0 0 0 0 1 0 1 0 1 1
151 Chesapeake Nightlock 147 D 1 1 Defense Pull NaN NaN ... 0 0 0 1 0 0 0 0 0 0
156 Chesapeake Nightlock 42 O 2 1 Offense Catch AD Red ... 0 1 1 0 0 0 1 0 1 1
164 Chesapeake Nightlock 82 D 3 1 Defense Pull NaN NaN ... 0 0 0 1 1 0 0 0 1 1
177 Chesapeake Nightlock 88 D 3 2 Defense Pull NaN NaN ... 1 0 0 0 0 0 0 0 0 0
185 Chesapeake Nightlock 70 O 3 3 Offense Catch Angela Wootie ... 0 1 1 0 1 0 0 0 0 0
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
1985 Chesapeake Hot Metal 186 D 7 4 Defense Pull NaN NaN ... 1 1 0 0 0 0 1 0 1 1
1998 Chesapeake Hot Metal 32 D 8 4 Defense Pull NaN NaN ... 0 1 1 1 0 0 0 0 1 1
2002 Chesapeake Hot Metal 177 D 9 4 Defense Pull NaN NaN ... 1 0 0 0 0 0 0 1 1 1
2018 Chesapeake Hot Metal 62 D 10 4 Defense Pull NaN NaN ... 0 1 0 1 1 0 1 0 1 1
2029 Chesapeake Hot Metal 105 D 11 4 Defense PullOb NaN NaN ... 0 1 0 0 0 0 0 0 1 1
2039 Chesapeake Hot Metal 137 D 12 4 Defense Pull NaN NaN ... 0 0 0 0 1 0 1 0 1 1
2049 Chesapeake Hot Metal 32 D 12 5 Defense Pull NaN NaN ... 1 1 1 0 0 0 0 1 0 0
2051 Chesapeake Hot Metal 67 O 13 5 Offense Catch AD Angela ... 0 0 0 1 0 0 0 1 1 1
2064 Cackalackee Jackwagon 72 D 1 0 Defense Pull NaN NaN ... 0 0 0 1 1 0 0 0 1 1
2071 Cackalackee Jackwagon 29 D 2 0 Defense Pull NaN NaN ... 1 1 0 0 0 1 1 0 1 1
2075 Cackalackee Jackwagon 24 D 3 0 Defense Pull NaN NaN ... 0 0 0 1 1 1 0 0 1 1
2080 Cackalackee Jackwagon 410 D 4 0 Defense Pull NaN NaN ... 0 0 0 0 0 0 0 1 1 1
2104 Cackalackee Jackwagon 47 D 4 1 Defense Pull NaN NaN ... 1 1 0 0 0 0 1 1 0 0
2108 Cackalackee Jackwagon 127 O 4 2 Offense Catch Haley Angela ... 0 0 0 1 1 1 0 0 0 0
2119 Cackalackee Jackwagon 40 O 5 2 Offense Catch AD Cate ... 0 0 0 0 0 0 0 0 1 1
2128 Cackalackee Jackwagon 34 D 5 3 Defense Pull NaN NaN ... 1 0 0 1 0 0 1 1 0 0
2130 Cackalackee Jackwagon 61 O 6 3 Offense Catch Wootie Sam ... 0 1 0 0 1 1 0 0 1 1
2143 Cackalackee Jackwagon 117 D 6 4 Defense Pull NaN NaN ... 1 0 0 0 0 0 0 0 0 0
2148 Cackalackee Jackwagon 54 O 7 4 Offense Catch AD Wootie ... 0 1 0 1 0 0 1 0 1 1
2153 Cackalackee Jackwagon 42 D 7 5 Defense Pull NaN NaN ... 0 0 0 0 1 1 0 1 0 0
2155 Cackalackee Jackwagon 83 O 8 5 Offense Throwaway Wootie Anonymous ... 0 1 0 0 0 0 1 0 1 1
2159 Cackalackee Jackwagon 30 O 9 5 Offense Catch Haley Paige ... 1 0 0 1 0 0 0 0 1 1
2163 Cackalackee Jackwagon 96 D 10 5 Defense Pull NaN NaN ... 0 1 0 0 1 1 0 1 1 1
2173 Cackalackee Jackwagon 53 D 11 5 Defense Pull NaN NaN ... 1 0 0 0 0 1 0 0 1 1
2177 Cackalackee Jackwagon 97 D 12 5 Defense Pull NaN NaN ... 0 1 0 1 0 0 1 0 1 1
2187 Cackalackee Jackwagon 318 D 12 6 Defense Pull NaN NaN ... 0 1 0 1 0 0 0 1 0 0
2203 Cackalackee Jackwagon 131 O 13 6 Offense Catch Nubby Angela ... 1 0 0 0 1 0 0 0 1 1
2220 Cackalackee Jackwagon 45 D 14 6 Defense Pull NaN NaN ... 0 1 0 0 0 0 1 0 1 1
2226 Cackalackee Jackwagon 48 D 14 7 Defense Pull NaN NaN ... 1 0 0 1 0 1 0 1 0 0
2230 Cackalackee Jackwagon 171 O 15 7 Offense Throwaway Wootie Anonymous ... 0 0 0 0 1 0 0 0 1 1

280 rows × 46 columns

In [388]:
from numpy import *

vector_dict={}
vector_dict['Score'] = array(point_data['Score'])
for p in player_set:
    vector_dict[p]=array(point_data[p])
max(point_data["Hewey"])
Out[388]:
1.0
In [391]:
players = list(player_set)
best_player_dict = {}

for p in players:
    print p
    best_player_dict[p]=float(sum(vector_dict[p]*vector_dict['Score']))/float(sum(vector_dict[p]))

best_player_series = pd.Series([best_player_dict[p] for p in players], index=players)
best_player_series.sort(ascending = False)
best_player_series
AD
Snow
Angela
Phebe
Hewey
Annie
Wootie
Puppy
Red
Cate
Turtle
Nubby
Meg
Paige
Sam
Alicia
Haley
Mira
Allee
Kate
Lina
Out[391]:
AD        0.657343
Hewey     0.647059
Kate      0.623656
Meg       0.617021
Allee     0.607843
Mira      0.607477
Cate      0.598361
Angela    0.569444
Haley     0.561404
Turtle    0.552083
Paige     0.536232
Red       0.526786
Nubby     0.526316
Wootie    0.525926
Sam       0.520325
Alicia    0.500000
Lina      0.500000
Puppy     0.479167
Snow      0.475000
Annie     0.468354
Phebe     0.450000
dtype: float64
In [399]:
#players=best_player_series.index
In [400]:
pt_dict={}
for p in players:
    pt_dict[p]=sum(vector_dict[p])
pt_series = pd.Series([pt_dict[p] for p in players], index=players)
pt_series.sort(ascending = False)
pt_series
Out[400]:
Angela    144
AD        143
Wootie    135
Sam       123
Cate      122
Haley     114
Red       112
Mira      107
Hewey     102
Puppy      96
Turtle     96
Meg        94
Kate       93
Annie      79
Nubby      76
Paige      69
Lina       64
Phebe      60
Allee      51
Snow       40
Alicia     34
dtype: float64
In [401]:
pairs_dict={}
for i in range(len(players)):
    for j in range(i+1,len(players)):
        if sum(vector_dict[players[i]]*vector_dict[players[j]]) <6:
            pairs_dict[players[i]+" "+players[j]]=None
        else:
            pairs_dict[players[i]+" "+players[j]]=\
                float(sum(vector_dict[players[i]]*vector_dict[players[j]]*vector_dict['Score']))/\
                float(sum(vector_dict[players[i]]*vector_dict[players[j]]))
        
player_pairs = pairs_dict.keys()
pairs_series = pd.Series([pairs_dict[p] for p in player_pairs], index=player_pairs)
pairs_series.sort(ascending=False)
pairs_series
Out[401]:
Hewey Meg       0.846154
AD Hewey        0.764706
Hewey Kate      0.758621
Mira Paige      0.750000
AD Allee        0.739130
Allee Sam       0.736842
AD Angela       0.727273
Hewey Cate      0.720000
Hewey Mira      0.720000
Hewey Allee     0.714286
Meg Turtle      0.714286
Haley Nubby     0.714286
Kate Alicia     0.714286
Haley Alicia    0.714286
AD Meg          0.708333
...
Wootie Snow     0.350000
Alicia Phebe    0.333333
Paige Annie     0.333333
Sam Alicia      0.333333
Nubby Lina      0.312500
Nubby Phebe     0.294118
Wootie Phebe    0.291667
Mira Alicia     0.285714
Red Annie       0.275862
Puppy Annie     0.260870
Mira Snow       0.250000
Alicia Snow          NaN
Allee Alicia         NaN
Allee Annie          NaN
Snow Annie           NaN
Length: 210, dtype: float64
In [402]:
team_scoring_pct=float(sum(vector_dict['Score']))/float(len(vector_dict['Score']))
team_scoring_pct
Out[402]:
0.5607142857142857
In [403]:
pairs_array=zeros((len(players),len(players)))
nothing=0.0

for i in range(len(players)):
    for j in range(len(players)):
        # pairs_matrix[i][j]=i+j
        if sum(vector_dict[players[i]]*vector_dict[players[j]]) <6:
            pairs_array[i][j]=nothing
        else:
            pairs_array[i][j]=\
                float(sum(vector_dict[players[i]]*vector_dict[players[j]]*vector_dict['Score']))/\
                float(sum(vector_dict[players[i]]*vector_dict[players[j]]))

import matplotlib
from pylab import *

colors = [('white')] + [(cm.jet(i)) for i in xrange(1,256)]
new_map = matplotlib.colors.LinearSegmentedColormap.from_list('new_map', colors, N=256)

figure(figsize=(9,8))
pcolor(pairs_array, cmap=new_map)
axis([0, len(players), 0, len(players)])
xticks(range(len(players)), players, rotation='vertical', ha='left')
yticks(range(len(players)), players, rotation=45)
colorbar()
savefig('map.png')
In [ ]: