Update app.py
Browse files
app.py
CHANGED
|
@@ -186,16 +186,21 @@ def server(input, output, session):
|
|
| 186 |
game_type = [input.type_input()])
|
| 187 |
|
| 188 |
data_list = scrape.get_data(game_list_input = game_list[:])
|
| 189 |
-
df = (stuff_apply.stuff_apply(fe.feature_engineering(update.update(scrape.get_data_df(data_list = data_list).filter(
|
| 190 |
-
(pl.col("pitcher_id") == player_input)&
|
| 191 |
-
(pl.col("is_pitch") == True)&
|
| 192 |
-
(pl.col("start_speed") >= 50)&
|
| 193 |
-
(pl.col('batter_hand').is_in(split_dict_hand[input.split_id()]))
|
| 194 |
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 199 |
|
| 200 |
@render.ui
|
| 201 |
@reactive.event(input.player_button, input.year_input, input.level_input, input.type_input,ignore_none=False)
|
|
@@ -252,7 +257,13 @@ def server(input, output, session):
|
|
| 252 |
print(year_input, sport_id, player_input, start_date, end_date)
|
| 253 |
|
| 254 |
df = cached_data()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 255 |
df = df.clone()
|
|
|
|
| 256 |
|
| 257 |
p.set(0.6, "Creating plot...")
|
| 258 |
|
|
|
|
| 186 |
game_type = [input.type_input()])
|
| 187 |
|
| 188 |
data_list = scrape.get_data(game_list_input = game_list[:])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 189 |
|
| 190 |
+
try:
|
| 191 |
+
df = (stuff_apply.stuff_apply(fe.feature_engineering(update.update(scrape.get_data_df(data_list = data_list).filter(
|
| 192 |
+
(pl.col("pitcher_id") == player_input)&
|
| 193 |
+
(pl.col("is_pitch") == True)&
|
| 194 |
+
(pl.col("start_speed") >= 50)&
|
| 195 |
+
(pl.col('batter_hand').is_in(split_dict_hand[input.split_id()]))
|
| 196 |
+
|
| 197 |
+
)))).with_columns(
|
| 198 |
+
pl.col('pitch_type').count().over('pitch_type').alias('pitch_count')
|
| 199 |
+
))
|
| 200 |
+
return df
|
| 201 |
+
except: TypeError
|
| 202 |
+
return None
|
| 203 |
+
|
| 204 |
|
| 205 |
@render.ui
|
| 206 |
@reactive.event(input.player_button, input.year_input, input.level_input, input.type_input,ignore_none=False)
|
|
|
|
| 257 |
print(year_input, sport_id, player_input, start_date, end_date)
|
| 258 |
|
| 259 |
df = cached_data()
|
| 260 |
+
|
| 261 |
+
if df is None:
|
| 262 |
+
fig = plt.figure(figsize=(26,26))
|
| 263 |
+
fig.text(x=0.5,y=0.5,s='No Statcast Data For This Pitcher',fontsize=36)
|
| 264 |
+
|
| 265 |
df = df.clone()
|
| 266 |
+
|
| 267 |
|
| 268 |
p.set(0.6, "Creating plot...")
|
| 269 |
|