patrickramos commited on
Commit
ce6c66c
·
1 Parent(s): a020f9c

Handle days with no games for daily leaderboard

Browse files
Files changed (1) hide show
  1. 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
- Table(
127
- (
128
- whiffs
129
- ),
130
- column_definitions=[
131
- ColumnDefinition(name="Rank", title="Rank", width=0.25),
132
- ColumnDefinition(name='Team', title='Team', width=0.25, plot_fn=circled_image, textprops={'ha': 'center'}),
133
- ColumnDefinition(name="Name", title="Player", textprops={'ha': 'left'}),
134
- ColumnDefinition(name="Whiffs", title="#", width=0.25)
135
- ],
136
- ax=whiff_ax
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
- Table(
152
- velos,
153
- column_definitions=[
154
- ColumnDefinition(name="Rank", title="Rank", width=0.25),
155
- ColumnDefinition(name='Team', title='Team', width=0.25, plot_fn=circled_image, textprops={'ha': 'center'}),
156
- ColumnDefinition(name="Name", title="Player", textprops={'ha': 'left'}),
157
- ColumnDefinition(name="KPH", title="KPH", width=0.25),
158
- ColumnDefinition(name='MPH', title='MPH', width=0.25)
159
- ],
160
- ax=velo_ax
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):