openhands commited on
Commit
5d82fab
·
1 Parent(s): fb3d0db

Fix score formatting to avoid coercing NaN to 0; show 'Not Submitted' instead.\n\nCo-authored-by: openhands <[email protected]>

Browse files
Files changed (1) hide show
  1. leaderboard_transformer.py +5 -8
leaderboard_transformer.py CHANGED
@@ -584,19 +584,16 @@ def format_score_column(df: pd.DataFrame, score_col_name: str) -> pd.DataFrame:
584
  status_color = "#ec4899" # The same color as your other status text
585
  is_overall_score = (score_col_name == "Overall Score")
586
 
587
- # First, fill any NaN values with 0 so we only have one case to handle.
588
- # We must use reassignment to avoid the SettingWithCopyWarning.
589
- df[score_col_name] = df[score_col_name].fillna(0)
590
-
591
  def apply_formatting(score_value):
592
- # Now, we just check if the value is 0.
593
- if score_value == 0:
 
 
 
594
  formatted = f'<span style="color: {status_color};">0.0</span>'
595
- # For all other numbers, format them for consistency.
596
  elif isinstance(score_value, (int, float)):
597
  formatted = f"{score_value:.3f}"
598
  else:
599
- # Fallback for any unexpected non-numeric data
600
  formatted = str(score_value)
601
 
602
  # Make Overall Score bold
 
584
  status_color = "#ec4899" # The same color as your other status text
585
  is_overall_score = (score_col_name == "Overall Score")
586
 
 
 
 
 
587
  def apply_formatting(score_value):
588
+ # Explicitly handle missing values without turning them into zeros
589
+ if pd.isna(score_value):
590
+ return f'<span style="color: {status_color};">Not Submitted</span>'
591
+ # Show true zero distinctly
592
+ if isinstance(score_value, (int, float)) and score_value == 0:
593
  formatted = f'<span style="color: {status_color};">0.0</span>'
 
594
  elif isinstance(score_value, (int, float)):
595
  formatted = f"{score_value:.3f}"
596
  else:
 
597
  formatted = str(score_value)
598
 
599
  # Make Overall Score bold