Update app.py
Browse files
app.py
CHANGED
|
@@ -308,22 +308,23 @@ def server(input, output, session):
|
|
| 308 |
end_date = end_date,
|
| 309 |
game_type = [input.type_input()])
|
| 310 |
|
| 311 |
-
|
| 312 |
-
|
| 313 |
-
|
| 314 |
-
|
| 315 |
-
|
| 316 |
-
|
| 317 |
-
|
| 318 |
-
|
| 319 |
-
|
| 320 |
-
|
| 321 |
-
|
| 322 |
-
prop_percent=(pl.col('is_pitch') / pl.col('is_pitch').sum()).over("pitch_type"),
|
| 323 |
-
prop=pl.col('is_pitch').sum().over("pitch_type")
|
| 324 |
-
)
|
| 325 |
|
| 326 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 327 |
|
| 328 |
@render.ui
|
| 329 |
@reactive.event(input.player_button, input.year_input, input.level_input, input.type_input,ignore_none=False)
|
|
@@ -385,8 +386,16 @@ def server(input, output, session):
|
|
| 385 |
def in_brush():
|
| 386 |
# if input.plot_brush() is None: # Note: changed to match the brush ID
|
| 387 |
# return None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 388 |
brushed_df = pl.DataFrame(brushed_points(
|
| 389 |
-
|
| 390 |
input.plot_brush(),
|
| 391 |
xvar="hb",
|
| 392 |
yvar="ivb",
|
|
|
|
| 308 |
end_date = end_date,
|
| 309 |
game_type = [input.type_input()])
|
| 310 |
|
| 311 |
+
try:
|
| 312 |
+
df = (stuff_apply.stuff_apply(fe.feature_engineering(update.update(scrape.get_data_df(data_list = data_list).filter(
|
| 313 |
+
(pl.col("pitcher_id") == player_input)&
|
| 314 |
+
(pl.col("is_pitch") == True)&
|
| 315 |
+
(pl.col("start_speed") >= 50)&
|
| 316 |
+
(pl.col('batter_hand').is_in(split_dict_hand[input.split_id()]))
|
| 317 |
+
|
| 318 |
+
)))).with_columns(
|
| 319 |
+
pl.col('pitch_type').count().over('pitch_type').alias('pitch_count')
|
| 320 |
+
))
|
| 321 |
+
return df
|
|
|
|
|
|
|
|
|
|
| 322 |
|
| 323 |
+
|
| 324 |
+
except TypeError:
|
| 325 |
+
print("NONE")
|
| 326 |
+
return None
|
| 327 |
+
|
| 328 |
|
| 329 |
@render.ui
|
| 330 |
@reactive.event(input.player_button, input.year_input, input.level_input, input.type_input,ignore_none=False)
|
|
|
|
| 386 |
def in_brush():
|
| 387 |
# if input.plot_brush() is None: # Note: changed to match the brush ID
|
| 388 |
# return None
|
| 389 |
+
|
| 390 |
+
|
| 391 |
+
df = cached_data()
|
| 392 |
+
if df is None:
|
| 393 |
+
fig = plt.figure(figsize=(10,10))
|
| 394 |
+
fig.text(x=0.1,y=0.9,s='No Statcast Data For This Pitcher',fontsize=24,ha='left')
|
| 395 |
+
return fig
|
| 396 |
+
|
| 397 |
brushed_df = pl.DataFrame(brushed_points(
|
| 398 |
+
df.to_pandas(),
|
| 399 |
input.plot_brush(),
|
| 400 |
xvar="hb",
|
| 401 |
yvar="ivb",
|