Update app.py
Browse files
app.py
CHANGED
|
@@ -376,12 +376,22 @@ def server(input, output, session):
|
|
| 376 |
'x0',
|
| 377 |
'z0']
|
| 378 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 379 |
selection = [['pitcher_id','pitcher_name','batter_id','batter_name','pitcher_hand',
|
| 380 |
'batter_hand','balls','strikes','play_code','event_type','pitch_type','vaa','haa']+features_table+['tj_stuff_plus']]
|
| 381 |
|
| 382 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 383 |
return render.DataGrid(
|
| 384 |
-
df.select(
|
| 385 |
row_selection_mode='multiple',
|
| 386 |
height=None,
|
| 387 |
width='fit-content',
|
|
|
|
| 376 |
'x0',
|
| 377 |
'z0']
|
| 378 |
|
| 379 |
+
|
| 380 |
+
# Assuming `df` is your DataFrame and `features_table` contains column names as strings.
|
| 381 |
+
float_columns = [col for col in df.columns if df[col].dtype in [pl.Float32, pl.Float64]]
|
| 382 |
+
|
| 383 |
+
|
| 384 |
selection = [['pitcher_id','pitcher_name','batter_id','batter_name','pitcher_hand',
|
| 385 |
'batter_hand','balls','strikes','play_code','event_type','pitch_type','vaa','haa']+features_table+['tj_stuff_plus']]
|
| 386 |
|
| 387 |
+
|
| 388 |
+
# Applying the rounding only to float columns
|
| 389 |
+
rounded_selection = [
|
| 390 |
+
df[col].round(1) if col in float_columns else df[col] for col in selection
|
| 391 |
+
]
|
| 392 |
+
|
| 393 |
return render.DataGrid(
|
| 394 |
+
df.select(rounded_selection),
|
| 395 |
row_selection_mode='multiple',
|
| 396 |
height=None,
|
| 397 |
width='fit-content',
|