Spaces:
Sleeping
Sleeping
Commit
·
ce6c66c
1
Parent(s):
a020f9c
Handle days with no games for daily leaderboard
Browse files- daily_weekly_leaderboard.py +29 -24
daily_weekly_leaderboard.py
CHANGED
|
@@ -123,18 +123,21 @@ def plot_tables(whiffs, velos, time_type, subheader):
|
|
| 123 |
whiffs = whiffs.set_index('Rank')
|
| 124 |
else:
|
| 125 |
whiffs.index = pd.Series(range(1, len(whiffs)+1), name='Rank')
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
|
|
|
|
|
|
|
|
|
| 138 |
whiff_fig.suptitle(f'{time_type} Whiff Leaderboard\n{subheader}')
|
| 139 |
|
| 140 |
velo_fig, velo_ax = plt.subplots(figsize=(4, 6))
|
|
@@ -148,19 +151,21 @@ def plot_tables(whiffs, velos, time_type, subheader):
|
|
| 148 |
velos = velos.set_index('Rank')
|
| 149 |
else:
|
| 150 |
velos.index = pd.Series(range(1, len(velos)+1), name='Rank')
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
|
|
|
|
|
|
|
|
|
| 162 |
velo_fig.suptitle(f'{time_type} Velocity Leaderboard\n{subheader}')
|
| 163 |
-
|
| 164 |
return whiff_fig, velo_fig
|
| 165 |
|
| 166 |
def go_back_day(date):
|
|
|
|
| 123 |
whiffs = whiffs.set_index('Rank')
|
| 124 |
else:
|
| 125 |
whiffs.index = pd.Series(range(1, len(whiffs)+1), name='Rank')
|
| 126 |
+
if len(whiffs) > 0:
|
| 127 |
+
Table(
|
| 128 |
+
(
|
| 129 |
+
whiffs
|
| 130 |
+
),
|
| 131 |
+
column_definitions=[
|
| 132 |
+
ColumnDefinition(name="Rank", title="Rank", width=0.25),
|
| 133 |
+
ColumnDefinition(name='Team', title='Team', width=0.25, plot_fn=circled_image, textprops={'ha': 'center'}),
|
| 134 |
+
ColumnDefinition(name="Name", title="Player", textprops={'ha': 'left'}),
|
| 135 |
+
ColumnDefinition(name="Whiffs", title="#", width=0.25)
|
| 136 |
+
],
|
| 137 |
+
ax=whiff_ax
|
| 138 |
+
)
|
| 139 |
+
else:
|
| 140 |
+
whiff_ax.axis('off')
|
| 141 |
whiff_fig.suptitle(f'{time_type} Whiff Leaderboard\n{subheader}')
|
| 142 |
|
| 143 |
velo_fig, velo_ax = plt.subplots(figsize=(4, 6))
|
|
|
|
| 151 |
velos = velos.set_index('Rank')
|
| 152 |
else:
|
| 153 |
velos.index = pd.Series(range(1, len(velos)+1), name='Rank')
|
| 154 |
+
if len(velos) > 0:
|
| 155 |
+
Table(
|
| 156 |
+
velos,
|
| 157 |
+
column_definitions=[
|
| 158 |
+
ColumnDefinition(name="Rank", title="Rank", width=0.25),
|
| 159 |
+
ColumnDefinition(name='Team', title='Team', width=0.25, plot_fn=circled_image, textprops={'ha': 'center'}),
|
| 160 |
+
ColumnDefinition(name="Name", title="Player", textprops={'ha': 'left'}),
|
| 161 |
+
ColumnDefinition(name="KPH", title="KPH", width=0.25),
|
| 162 |
+
ColumnDefinition(name='MPH', title='MPH', width=0.25)
|
| 163 |
+
],
|
| 164 |
+
ax=velo_ax
|
| 165 |
+
)
|
| 166 |
+
else:
|
| 167 |
+
velo_ax.axis('off')
|
| 168 |
velo_fig.suptitle(f'{time_type} Velocity Leaderboard\n{subheader}')
|
|
|
|
| 169 |
return whiff_fig, velo_fig
|
| 170 |
|
| 171 |
def go_back_day(date):
|