Spaces:
Running
Running
Commit
·
1573bb0
1
Parent(s):
847006b
Add MPH to pitcher dashboard
Browse files- data.py +6 -1
- gradio_function.py +11 -2
- pitcher_dashboard.py +1 -1
data.py
CHANGED
@@ -286,7 +286,12 @@ def compute_pitch_stats(df):
|
|
286 |
pitch_stats = compute_pitch_stats(df)
|
287 |
|
288 |
def compute_league_pitch_stats(df):
|
289 |
-
return
|
|
|
|
|
|
|
|
|
|
|
290 |
|
291 |
league_pitch_stats = compute_league_pitch_stats(df)
|
292 |
|
|
|
286 |
pitch_stats = compute_pitch_stats(df)
|
287 |
|
288 |
def compute_league_pitch_stats(df):
|
289 |
+
return (
|
290 |
+
df
|
291 |
+
.group_by('pitch_name')
|
292 |
+
.agg(pl.col('release_speed').mean().round(1).alias('Velocity (KPH)'))
|
293 |
+
.with_columns(pl.col('Velocity (KPH)').truediv(1.609).round(1).alias('Velocity (MPH)'))
|
294 |
+
)
|
295 |
|
296 |
league_pitch_stats = compute_league_pitch_stats(df)
|
297 |
|
gradio_function.py
CHANGED
@@ -408,9 +408,18 @@ def plot_pitch_cards(df, league_df, pitch_stats, handedness):
|
|
408 |
def update_velo_stats(pitch_stats, league_pitch_stats):
|
409 |
return (
|
410 |
pitch_stats
|
411 |
-
.select(
|
|
|
|
|
|
|
|
|
|
|
412 |
.join(
|
413 |
-
league_pitch_stats.select(
|
|
|
|
|
|
|
|
|
414 |
on='Pitch',
|
415 |
how='inner'
|
416 |
)
|
|
|
408 |
def update_velo_stats(pitch_stats, league_pitch_stats):
|
409 |
return (
|
410 |
pitch_stats
|
411 |
+
.select(
|
412 |
+
pl.col('pitch_name').alias('Pitch'),
|
413 |
+
pl.col('Velocity (KPH)').alias('Avg. Velo (KPH)'),
|
414 |
+
pl.col('Velocity (MPH)').alias('Avg. Velo (MPH)'),
|
415 |
+
pl.col('Count')
|
416 |
+
)
|
417 |
.join(
|
418 |
+
league_pitch_stats.select(
|
419 |
+
pl.col('pitch_name').alias('Pitch'),
|
420 |
+
pl.col('Velocity (KPH)').alias('League Avg. Velo (KPH)'),
|
421 |
+
pl.col('Velocity (MPH)').alias('Leauge Avg. Velo (MPH)'),
|
422 |
+
),
|
423 |
on='Pitch',
|
424 |
how='inner'
|
425 |
)
|
pitcher_dashboard.py
CHANGED
@@ -48,7 +48,7 @@ def create_pitcher_dashboard():
|
|
48 |
loc_summary = gr.Plot(label='Overall location')
|
49 |
|
50 |
gr.Markdown('## Pitch Velocity')
|
51 |
-
velo_stats = gr.DataFrame(pl.DataFrame([{'Avg. Velo': None, 'League Avg. Velo': None}]), interactive=False, label='Pitch Velocity')
|
52 |
|
53 |
max_locs = len(jp_pitch_to_en_pitch)
|
54 |
locs_per_row = 4
|
|
|
48 |
loc_summary = gr.Plot(label='Overall location')
|
49 |
|
50 |
gr.Markdown('## Pitch Velocity')
|
51 |
+
velo_stats = gr.DataFrame(pl.DataFrame([{'Avg. Velo (KPH)': None, 'Avg. Velo (MPH)': None, 'League Avg. Velo (KPH)': None, 'League Avg. Velo (MPH)': None}]), interactive=False, label='Pitch Velocity')
|
52 |
|
53 |
max_locs = len(jp_pitch_to_en_pitch)
|
54 |
locs_per_row = 4
|