Spaces:
Sleeping
Sleeping
mode
Browse files
app.py
CHANGED
|
@@ -290,20 +290,18 @@ def init_leaderboard(dataframe, visible_columns=None):
|
|
| 290 |
# Format floats to exactly 3 decimal places, preserving trailing zeros
|
| 291 |
display_df[col] = display_df[col].apply(lambda x: f"{x:.3f}" if pd.notna(x) else None)
|
| 292 |
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
# Get display names for headers
|
| 296 |
column_info_map = {f.name: getattr(GUARDBENCH_COLUMN, f.name) for f in fields(GUARDBENCH_COLUMN)}
|
| 297 |
-
|
| 298 |
-
|
| 299 |
-
|
| 300 |
-
|
| 301 |
-
|
| 302 |
-
|
|
|
|
| 303 |
|
| 304 |
return gr.Dataframe(
|
| 305 |
-
value=styler,
|
| 306 |
-
headers=display_headers,
|
| 307 |
datatype=datatypes, # Now using the correct format
|
| 308 |
interactive=False,
|
| 309 |
wrap=True,
|
|
|
|
| 290 |
# Format floats to exactly 3 decimal places, preserving trailing zeros
|
| 291 |
display_df[col] = display_df[col].apply(lambda x: f"{x:.3f}" if pd.notna(x) else None)
|
| 292 |
|
| 293 |
+
# Get display names and create mapping
|
|
|
|
|
|
|
| 294 |
column_info_map = {f.name: getattr(GUARDBENCH_COLUMN, f.name) for f in fields(GUARDBENCH_COLUMN)}
|
| 295 |
+
column_mapping = {col: column_info_map.get(col, ColumnInfo(col, col)).display_name for col in visible_columns}
|
| 296 |
+
|
| 297 |
+
# Rename columns in the DataFrame
|
| 298 |
+
display_df.rename(columns=column_mapping, inplace=True)
|
| 299 |
+
|
| 300 |
+
# Apply styling - note: styling might need adjustment if it relies on column names
|
| 301 |
+
styler = display_df.style.set_properties(**{'text-align': 'right'})
|
| 302 |
|
| 303 |
return gr.Dataframe(
|
| 304 |
+
value=styler, # Pass the DataFrame with renamed columns
|
|
|
|
| 305 |
datatype=datatypes, # Now using the correct format
|
| 306 |
interactive=False,
|
| 307 |
wrap=True,
|