Spaces:
Build error
Build error
Commit
·
da63d73
1
Parent(s):
025c1eb
Add plotted tables for easier leaderboard sharing
Browse files
daily_weekly_leaderboard.py
CHANGED
@@ -31,13 +31,13 @@ def filter_pitcher_leaderboard_by_date(date, *args, **kwargs):
|
|
31 |
weekly_whiffs, weekly_velos = compute_pitcher_leaderboards(week_df, *args, **kwargs)
|
32 |
return (
|
33 |
f'<center><h1>Daily Leaderboard<h1><h2>{date.strftime("%B %d, %Y")}</h2><h3>{date.strftime("%A")}</h3></center>',
|
34 |
-
f'<center><h1>Weekly Leaderboard<h1><h2>{monday.strftime("%B %d, %Y")} to {sunday.strftime("%B %d, %Y")}</h2><h3>{monday.strftime("%A")} to {sunday.strftime("%A")}
|
35 |
daily_whiffs,
|
36 |
daily_velos,
|
37 |
weekly_whiffs,
|
38 |
weekly_velos,
|
39 |
-
plot_tables(daily_whiffs, daily_velos, 'Daily'),
|
40 |
-
plot_tables(weekly_whiffs, weekly_velos, 'Weekly'),
|
41 |
gr.update(interactive=True),
|
42 |
gr.update(interactive=True),
|
43 |
gr.update(interactive=True),
|
@@ -107,7 +107,7 @@ def compute_pitcher_leaderboards(df, top_players, strict, ignore_zero_whiffs, sh
|
|
107 |
# )
|
108 |
|
109 |
|
110 |
-
def plot_tables(whiffs, velos, time_type):
|
111 |
fig, (whiff_ax, velo_ax) = plt.subplots(ncols=2, constrained_layout=True, sharey=True)
|
112 |
|
113 |
whiffs = whiffs.to_pandas()
|
@@ -142,7 +142,7 @@ def plot_tables(whiffs, velos, time_type):
|
|
142 |
)
|
143 |
velo_ax.set_title('Velocity')
|
144 |
|
145 |
-
fig.suptitle(f'{time_type} Leaderboard')
|
146 |
return fig
|
147 |
|
148 |
def go_back_day(date):
|
|
|
31 |
weekly_whiffs, weekly_velos = compute_pitcher_leaderboards(week_df, *args, **kwargs)
|
32 |
return (
|
33 |
f'<center><h1>Daily Leaderboard<h1><h2>{date.strftime("%B %d, %Y")}</h2><h3>{date.strftime("%A")}</h3></center>',
|
34 |
+
f'<center><h1>Weekly Leaderboard<h1><h2>{monday.strftime("%B %d, %Y")} to {sunday.strftime("%B %d, %Y")}</h2><h3>{monday.strftime("%A")} to {sunday.strftime("%A")}</h3></center>',
|
35 |
daily_whiffs,
|
36 |
daily_velos,
|
37 |
weekly_whiffs,
|
38 |
weekly_velos,
|
39 |
+
plot_tables(daily_whiffs, daily_velos, 'Daily', f'{date.strftime("%B %d, %Y")}\n{date.strftime("%A")}'),
|
40 |
+
plot_tables(weekly_whiffs, weekly_velos, 'Weekly', f'{monday.strftime("%B %d, %Y")} to {sunday.strftime("%B %d, %Y")}\n{monday.strftime("%A")} to {sunday.strftime("%A")}'),
|
41 |
gr.update(interactive=True),
|
42 |
gr.update(interactive=True),
|
43 |
gr.update(interactive=True),
|
|
|
107 |
# )
|
108 |
|
109 |
|
110 |
+
def plot_tables(whiffs, velos, time_type, subheader):
|
111 |
fig, (whiff_ax, velo_ax) = plt.subplots(ncols=2, constrained_layout=True, sharey=True)
|
112 |
|
113 |
whiffs = whiffs.to_pandas()
|
|
|
142 |
)
|
143 |
velo_ax.set_title('Velocity')
|
144 |
|
145 |
+
fig.suptitle(f'{time_type} Leaderboard\n{subheader}')
|
146 |
return fig
|
147 |
|
148 |
def go_back_day(date):
|