apsys commited on
Commit
40443c1
·
1 Parent(s): 6f09c54

style theme

Browse files
Files changed (1) hide show
  1. app.py +16 -2
app.py CHANGED
@@ -276,10 +276,24 @@ def init_leaderboard(dataframe, visible_columns=None):
276
  # Avoid rounding integer columns like counts
277
  if not pd.api.types.is_integer_dtype(display_df[col]):
278
  # Format floats to exactly 3 decimal places, preserving trailing zeros
279
- display_df[col] = display_df[col].apply(lambda x: f"{x:.3f}" if pd.notna(x) else None)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
280
 
281
  return gr.Dataframe(
282
- value=display_df,
283
  headers=visible_columns,
284
  datatype=datatypes, # Now using the correct format
285
  interactive=False,
 
276
  # Avoid rounding integer columns like counts
277
  if not pd.api.types.is_integer_dtype(display_df[col]):
278
  # Format floats to exactly 3 decimal places, preserving trailing zeros
279
+ # display_df[col] = display_df[col].apply(lambda x: f"{x:.3f}" if pd.notna(x) else None)
280
+ pass # Formatting will be handled by Styler
281
+
282
+ # Create Styler object for formatting and alignment
283
+ styler = display_df.style
284
+
285
+ # Format numeric columns to 3 decimal places
286
+ format_dict = {}
287
+ for col in numeric_cols:
288
+ if not pd.api.types.is_integer_dtype(display_df[col]):
289
+ format_dict[col] = "{:.3f}"
290
+ styler = styler.format(format_dict, na_rep="") # Use empty string for NaNs
291
+
292
+ # Right-align all columns (Gradio might do this for numbers, but explicit is better)
293
+ styler = styler.set_properties(**{'text-align': 'right'})
294
 
295
  return gr.Dataframe(
296
+ value=styler, # Pass the Styler object
297
  headers=visible_columns,
298
  datatype=datatypes, # Now using the correct format
299
  interactive=False,