lschlessinger commited on
Commit
17519fc
·
1 Parent(s): d963711

patch: handle missing scores

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -148,16 +148,17 @@ def get_rating_over_time_fig(df: pd.DataFrame, is_tournament: bool):
148
  return fig
149
 
150
 
151
- def get_max_int(int_csv_str: str) -> int:
152
- """Get the max int from an int CSV."""
153
- ints = [int(i.strip()) for i in int_csv_str.split(',') if i]
154
  return max(ints)
155
 
156
 
157
  def get_match_with_longest_game(df: pd.DataFrame, is_tournament: bool) -> Optional[pd.DataFrame]:
158
  if not is_tournament:
159
  return None
160
- return df.loc[[np.argmax(df.scores.apply(get_max_int))]]
 
161
 
162
 
163
  def get_win_loss_record_str(group_df) -> str:
 
148
  return fig
149
 
150
 
151
+ def get_max_abs_int(int_csv_str: str) -> int:
152
+ """Get the max absolute value int from an int CSV."""
153
+ ints = [abs(int(i.strip())) for i in int_csv_str.split(',') if i]
154
  return max(ints)
155
 
156
 
157
  def get_match_with_longest_game(df: pd.DataFrame, is_tournament: bool) -> Optional[pd.DataFrame]:
158
  if not is_tournament:
159
  return None
160
+ df_non_null = df.loc[~df.scores.isna()]
161
+ return df_non_null.iloc[[df_non_null.scores.apply(get_max_abs_int).argmax()]]
162
 
163
 
164
  def get_win_loss_record_str(group_df) -> str: