-
Notifications
You must be signed in to change notification settings - Fork 0
/
theWeatherEffectFinalReceptions.py
257 lines (224 loc) · 12.4 KB
/
theWeatherEffectFinalReceptions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
import nflgame
totalColdReceptions = 0
totalColdRecYards = 0
totalColdGames = 0
totalChillyReceptions = 0
totalChillyRecYards = 0
totalChillyGames = 0
totalMediumReceptions = 0
totalMediumRecYards = 0
totalMediumGames = 0
totalWarmReceptions = 0
totalWarmRecYards = 0
totalWarmGames = 0
totalHotReceptions = 0
totalHotRecYards = 0
totalHotGames = 0
totalSnowReceptions = 0
totalSnowRecYards = 0
totalSnowGames = 0
totalRainReceptions = 0
totalRainRecYards = 0
totalRainGames = 0
totalWindReceptions = 0
totalWindRecYards = 0
totalWindGames = 0
totalPartlyCloudyDayReceptions = 0
totalPartlyCloudyDayRecYards = 0
totalPartlyCloudyDayGames = 0
totalPartlyCloudyNightReceptions = 0
totalPartlyCloudyNightRecYards = 0
totalPartlyCloudyNightGames = 0
totalCloudyReceptions = 0
totalCloudyRecYards = 0
totalCloudyGames = 0
totalFogReceptions = 0
totalFogRecYards = 0
totalFogGames = 0
totalNormalReceptions = 0
totalNormalRecYards = 0
totalNormalGames = 0
currentWeekLocations = dict()
currentGameTemp = dict()
currentGameWeatherCondition = dict()
currentWeekLocationAndTemperatures = dict()
currentWeekLocationAndWeatherCondition = dict()
with open('weatherCollection.txt') as f:
content = f.readlines()
# initialize a dictionary that holds the location of each game
count = 1
for current in content:
currentWeekLocations[count] = str(current[29:32])
count+=1
count = 1
# initialize 2 dictionaries that hold the temperature and the weather conditions
for current in content:
currentGameTemp[count] = current[13:15]
if "snow" in current:
currentGameWeatherCondition[count] = str(current[71:77])
elif "partly-cloudy-day" in current:
currentGameWeatherCondition[count] = str(current[71:89])
elif "rain" in current:
currentGameWeatherCondition[count] = str(current[71:77])
elif "partly-cloudy-night" in current:
currentGameWeatherCondition[count] = str(current[71:92])
elif "cloudy" in current:
currentGameWeatherCondition[count] = str(current[71:79])
elif "wind" in current:
currentGameWeatherCondition[count] = str(current[71:77])
elif "fog" in current:
currentGameWeatherCondition[count] = str(current[71:76])
elif "clear-day" in current:
currentGameWeatherCondition[count] = str(current[71:82])
if current == "\n":
currentGameTemp[count] = 0
currentGameWeatherCondition[count] = 0
count += 1
for i in currentGameTemp:
currentGameTemp[i] = int(currentGameTemp[i])
currentGame = 1
for year in range(2009, 2015):
for week in range(1, 18):
while not content[currentGame] == '\n':
currentWeekLocationAndTemperatures[currentWeekLocations[currentGame]] = currentGameTemp[currentGame]
currentWeekLocationAndWeatherCondition[currentWeekLocations[currentGame]] = currentGameWeatherCondition[currentGame]
currentGame += 1
currentWeekLocationAndTemperatures[currentWeekLocations[currentGame]] = currentGameTemp[currentGame]
currentWeekLocationAndWeatherCondition[currentWeekLocations[currentGame]] = currentGameWeatherCondition[currentGame]
currentGame += 2
for current in currentWeekLocationAndTemperatures:
print current, currentWeekLocationAndTemperatures[current]
print ""
games = nflgame.games(year, week, kind="REG")
players = nflgame.combine_game_stats(games)
plays = nflgame.combine_plays(games)
opponents = dict([(g.home, g.away) for g in games] + [(g.away, g.home) for g in games])
print year, week
for player in players.receiving().sort('receiving_yds').limit(50):
currentTeam = str(player.team)
if len(currentTeam) < 3:
currentTeam += " "
currentOpponentTeam = str(opponents[player.team])
if len(currentOpponentTeam) < 3:
currentOpponentTeam += " "
if player.home:
if (currentWeekLocationAndTemperatures[currentTeam] <= 10):
totalColdReceptions += player.receiving_rec
totalColdRecYards += player.receiving_yds
totalColdGames += 1
elif (currentWeekLocationAndTemperatures[currentTeam] > 10) and (currentWeekLocationAndTemperatures[currentTeam] <= 32):
totalChillyReceptions += player.receiving_rec
totalChillyRecYards += player.receiving_yds
totalChillyGames += 1
elif (currentWeekLocationAndTemperatures[currentTeam] > 32) and (currentWeekLocationAndTemperatures[currentTeam] <= 60):
totalMediumReceptions += player.receiving_rec
totalMediumRecYards += player.receiving_yds
totalMediumGames += 1
elif (currentWeekLocationAndTemperatures[currentTeam] > 60) and (currentWeekLocationAndTemperatures[currentTeam] <= 80):
totalWarmReceptions += player.receiving_rec
totalWarmRecYards += player.receiving_yds
totalWarmGames += 1
elif (currentWeekLocationAndTemperatures[currentTeam] > 80):
totalHotReceptions += player.receiving_rec
totalHotRecYards += player.receiving_yds
totalHotGames += 1
if currentWeekLocationAndWeatherCondition[currentTeam] == "snow\n":
totalSnowReceptions += player.receiving_rec
totalSnowRecYards += player.receiving_yds
totalSnowGames += 1
elif currentWeekLocationAndWeatherCondition[currentTeam] == "rain\n":
totalRainReceptions += player.receiving_rec
totalRainRecYards += player.receiving_yds
totalRainGames += 1
elif currentWeekLocationAndWeatherCondition[currentTeam] == "wind\n":
totalWindReceptions += player.receiving_rec
totalWindRecYards += player.receiving_yds
totalWindGames += 1
elif currentWeekLocationAndWeatherCondition[currentTeam] == "partly-cloudy-day\n":
totalPartlyCloudyDayReceptions += player.receiving_rec
totalPartlyCloudyDayRecYards += player.receiving_yds
totalPartlyCloudyDayGames += 1
elif currentWeekLocationAndWeatherCondition[currentTeam] == "partly-cloudy-night\n":
totalPartlyCloudyNightReceptions += player.receiving_rec
totalPartlyCloudyNightRecYards += player.receiving_yds
totalPartlyCloudyNightGames += 1
elif currentWeekLocationAndWeatherCondition[currentTeam] == "cloudy\n":
totalCloudyReceptions += player.receiving_rec
totalCloudyRecYards += player.receiving_yds
totalCloudyGames += 1
elif currentWeekLocationAndWeatherCondition[currentTeam] == "clear-day\n":
totalNormalReceptions += player.receiving_rec
totalNormalRecYards += player.receiving_yds
totalNormalGames += 1
elif currentWeekLocationAndWeatherCondition[currentTeam] == "fog\n":
totalFogReceptions += player.receiving_rec
totalFogRecYards += player.receiving_yds
totalFogGames += 1
else:
if (currentWeekLocationAndTemperatures[currentOpponentTeam] <= 10):
totalColdReceptions += player.receiving_rec
totalColdRecYards += player.receiving_yds
totalColdGames += 1
elif (currentWeekLocationAndTemperatures[currentOpponentTeam] > 10) and (currentWeekLocationAndTemperatures[currentOpponentTeam] <= 32):
totalChillyReceptions += player.receiving_rec
totalChillyRecYards += player.receiving_yds
totalChillyGames += 1
elif (currentWeekLocationAndTemperatures[currentOpponentTeam] > 32) and (currentWeekLocationAndTemperatures[currentOpponentTeam] <= 60):
totalMediumReceptions += player.receiving_rec
totalMediumRecYards += player.receiving_yds
totalMediumGames += 1
elif (currentWeekLocationAndTemperatures[currentOpponentTeam]) > 60 and (currentWeekLocationAndTemperatures[currentOpponentTeam] <= 80):
totalWarmReceptions += player.receiving_rec
totalWarmRecYards += player.receiving_yds
totalWarmGames += 1
elif (currentWeekLocationAndTemperatures[currentOpponentTeam] > 80):
totalHotReceptions += player.receiving_rec
totalHotRecYards += player.receiving_yds
totalHotGames += 1
if currentWeekLocationAndWeatherCondition[currentOpponentTeam] == "snow\n":
totalSnowReceptions += player.receiving_rec
totalSnowRecYards += player.receiving_yds
totalSnowGames += 1
elif currentWeekLocationAndWeatherCondition[currentOpponentTeam] == "rain\n":
totalRainReceptions += player.receiving_rec
totalRainRecYards += player.receiving_yds
totalRainGames += 1
elif currentWeekLocationAndWeatherCondition[currentOpponentTeam] == "wind\n":
totalWindReceptions += player.receiving_rec
totalWindRecYards += player.receiving_yds
totalWindGames += 1
elif currentWeekLocationAndWeatherCondition[currentOpponentTeam] == "partly-cloudy-day\n":
totalPartlyCloudyDayReceptions += player.receiving_rec
totalPartlyCloudyDayRecYards += player.receiving_yds
totalPartlyCloudyDayGames += 1
elif currentWeekLocationAndWeatherCondition[currentOpponentTeam] == "partly-cloudy-night\n":
totalPartlyCloudyNightReceptions += player.receiving_rec
totalPartlyCloudyNightRecYards += player.receiving_yds
totalPartlyCloudyNightGames += 1
elif currentWeekLocationAndWeatherCondition[currentOpponentTeam] == "cloudy\n":
totalCloudyReceptions += player.receiving_rec
totalCloudyRecYards += player.receiving_yds
totalCloudyGames += 1
elif currentWeekLocationAndWeatherCondition[currentOpponentTeam] == "clear-day\n":
totalNormalReceptions += player.receiving_rec
totalNormalRecYards += player.receiving_yds
totalNormalGames += 1
elif currentWeekLocationAndWeatherCondition[currentOpponentTeam] == "fog\n":
totalFogReceptions += player.receiving_rec
totalFogRecYards += player.receiving_yds
totalFogGames += 1
currentWeekLocationAndTemperatures.clear()
currentWeekLocationAndWeatherCondition.clear()
print "COLD STATS <10 :", float(float(totalColdRecYards)/float(totalColdReceptions)), float(float(totalColdReceptions)/float(totalColdGames)), float(float(totalColdRecYards) / float(totalColdGames))
print "CHILLY STATS 10< <32 :", float(float(totalChillyRecYards)/float(totalChillyReceptions)), float(float(totalChillyReceptions)/float(totalChillyGames)), float(float(totalChillyRecYards) / float(totalChillyGames))
print "MEDIUM STATS 32< <60 :", float(float(totalMediumRecYards)/float(totalMediumReceptions)), float(float(totalMediumReceptions)/float(totalMediumGames)), float(float(totalMediumRecYards) / float(totalMediumGames))
print "WARM STATS 60< <80 :", float(float(totalWarmRecYards)/float(totalWarmReceptions)), float(float(totalWarmReceptions)/float(totalWarmGames)), float(float(totalWarmRecYards) / float(totalWarmGames))
print "HOT STATS 80> :", float(float(totalHotRecYards)/float(totalHotReceptions)), float(float(totalHotReceptions)/float(totalHotGames)), float(float(totalHotRecYards) / float(totalHotGames))
print "SNOW STATS :", float(float(totalSnowRecYards)/float(totalSnowReceptions)), float(float(totalSnowReceptions)/float(totalSnowGames)), float(float(totalSnowRecYards) / float(totalSnowGames))
print "RAIN STATS :", float(float(totalRainRecYards)/float(totalRainReceptions)), float(float(totalRainReceptions)/float(totalRainGames)), float(float(totalRainRecYards) / float(totalRainGames))
print "WIND STATS :", float(float(totalWindRecYards)/float(totalWindReceptions)), float(float(totalWindReceptions)/float(totalWindGames)), float(float(totalWindRecYards) / float(totalWindGames))
print "FOG STATS :", float(float(totalFogRecYards)/float(totalFogReceptions)), float(float(totalFogReceptions)/float(totalFogGames)), float(float(totalFogRecYards) / float(totalFogGames))
print "NORMAL STATS :", float(float(totalNormalRecYards)/float(totalNormalReceptions)), float(float(totalNormalReceptions)/float(totalNormalGames)), float(float(totalNormalRecYards) / float(totalNormalGames))
print "PARTLY-CLOUDY-DAY STATS :", float(float(totalPartlyCloudyDayRecYards)/float(totalPartlyCloudyDayReceptions)), float(float(totalPartlyCloudyDayReceptions)/float(totalPartlyCloudyDayGames)), float(float(totalPartlyCloudyDayRecYards) / float(totalPartlyCloudyDayGames))
print "PARTLY-CLOUDY-NIGHT STATS:", float(float(totalPartlyCloudyNightRecYards)/float(totalPartlyCloudyNightReceptions)), float(float(totalPartlyCloudyNightReceptions)/float(totalPartlyCloudyNightGames)), float(float(totalPartlyCloudyNightRecYards) / float(totalPartlyCloudyNightGames))
print "CLOUDY STATS :", float(float(totalCloudyRecYards)/float(totalCloudyReceptions)), float(float(totalCloudyReceptions)/float(totalCloudyGames)), float(float(totalCloudyRecYards) / float(totalCloudyGames))