Spaces:
Running
Running
openhands
commited on
Commit
·
2b7cd27
1
Parent(s):
73df5bb
Format date column to show only date, not time
Browse files- Add format_date_column function to leaderboard_transformer.py
- Apply date formatting in ui_components.py for all table displays
- Strips time portion from ISO datetime strings (e.g. 2025-11-24T19:56:00 -> 2025-11-24)
- leaderboard_transformer.py +36 -0
- ui_components.py +9 -0
leaderboard_transformer.py
CHANGED
|
@@ -1360,6 +1360,42 @@ def format_runtime_column(df: pd.DataFrame, runtime_col_name: str) -> pd.DataFra
|
|
| 1360 |
return df
|
| 1361 |
|
| 1362 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1363 |
def get_pareto_df(data, cost_col=None, score_col=None):
|
| 1364 |
"""
|
| 1365 |
Calculate the Pareto frontier for the given data.
|
|
|
|
| 1360 |
return df
|
| 1361 |
|
| 1362 |
|
| 1363 |
+
def format_date_column(df: pd.DataFrame, date_col_name: str = "Date") -> pd.DataFrame:
|
| 1364 |
+
"""
|
| 1365 |
+
Formats a date column to show only the date part (YYYY-MM-DD), removing the time.
|
| 1366 |
+
|
| 1367 |
+
Args:
|
| 1368 |
+
df: The DataFrame to modify.
|
| 1369 |
+
date_col_name: The name of the date column to format (default: "Date").
|
| 1370 |
+
|
| 1371 |
+
Returns:
|
| 1372 |
+
The DataFrame with the formatted date column.
|
| 1373 |
+
"""
|
| 1374 |
+
if date_col_name not in df.columns:
|
| 1375 |
+
return df # Return the DataFrame unmodified if the column doesn't exist
|
| 1376 |
+
|
| 1377 |
+
def apply_date_formatting(date_value):
|
| 1378 |
+
if pd.isna(date_value) or date_value == '':
|
| 1379 |
+
return ''
|
| 1380 |
+
|
| 1381 |
+
# Handle ISO format strings like "2025-11-24T19:56:00.092865"
|
| 1382 |
+
if isinstance(date_value, str):
|
| 1383 |
+
# Extract just the date part (before the 'T')
|
| 1384 |
+
if 'T' in date_value:
|
| 1385 |
+
return date_value.split('T')[0]
|
| 1386 |
+
# If it's already in date format, return as-is
|
| 1387 |
+
return date_value[:10] if len(date_value) >= 10 else date_value
|
| 1388 |
+
|
| 1389 |
+
# Handle pandas Timestamp or datetime objects
|
| 1390 |
+
try:
|
| 1391 |
+
return pd.to_datetime(date_value).strftime('%Y-%m-%d')
|
| 1392 |
+
except (ValueError, TypeError):
|
| 1393 |
+
return str(date_value)
|
| 1394 |
+
|
| 1395 |
+
df[date_col_name] = df[date_col_name].apply(apply_date_formatting)
|
| 1396 |
+
return df
|
| 1397 |
+
|
| 1398 |
+
|
| 1399 |
def get_pareto_df(data, cost_col=None, score_col=None):
|
| 1400 |
"""
|
| 1401 |
Calculate the Pareto frontier for the given data.
|
ui_components.py
CHANGED
|
@@ -19,6 +19,7 @@ from leaderboard_transformer import (
|
|
| 19 |
format_cost_column,
|
| 20 |
format_score_column,
|
| 21 |
format_runtime_column,
|
|
|
|
| 22 |
get_pareto_df,
|
| 23 |
clean_llm_base_list,
|
| 24 |
get_company_from_model,
|
|
@@ -600,6 +601,10 @@ def create_leaderboard_display(
|
|
| 600 |
if "Runtime" in col:
|
| 601 |
df_display = format_runtime_column(df_display, col)
|
| 602 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 603 |
# Clean the Language Model column first
|
| 604 |
df_display['Language Model'] = df_display['Language Model'].apply(clean_llm_base_list)
|
| 605 |
|
|
@@ -1188,6 +1193,10 @@ def create_benchmark_details_display(
|
|
| 1188 |
if benchmark_runtime_col in benchmark_table_df.columns:
|
| 1189 |
benchmark_table_df = format_runtime_column(benchmark_table_df, benchmark_runtime_col)
|
| 1190 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1191 |
# Rename columns for a cleaner table display, as requested
|
| 1192 |
benchmark_table_df.rename(columns={
|
| 1193 |
benchmark_score_col: 'Score',
|
|
|
|
| 19 |
format_cost_column,
|
| 20 |
format_score_column,
|
| 21 |
format_runtime_column,
|
| 22 |
+
format_date_column,
|
| 23 |
get_pareto_df,
|
| 24 |
clean_llm_base_list,
|
| 25 |
get_company_from_model,
|
|
|
|
| 601 |
if "Runtime" in col:
|
| 602 |
df_display = format_runtime_column(df_display, col)
|
| 603 |
|
| 604 |
+
# Format Date column to show only date (not time)
|
| 605 |
+
if "Date" in df_display.columns:
|
| 606 |
+
df_display = format_date_column(df_display, "Date")
|
| 607 |
+
|
| 608 |
# Clean the Language Model column first
|
| 609 |
df_display['Language Model'] = df_display['Language Model'].apply(clean_llm_base_list)
|
| 610 |
|
|
|
|
| 1193 |
if benchmark_runtime_col in benchmark_table_df.columns:
|
| 1194 |
benchmark_table_df = format_runtime_column(benchmark_table_df, benchmark_runtime_col)
|
| 1195 |
|
| 1196 |
+
# Format Date column to show only date (not time)
|
| 1197 |
+
if "Date" in benchmark_table_df.columns:
|
| 1198 |
+
benchmark_table_df = format_date_column(benchmark_table_df, "Date")
|
| 1199 |
+
|
| 1200 |
# Rename columns for a cleaner table display, as requested
|
| 1201 |
benchmark_table_df.rename(columns={
|
| 1202 |
benchmark_score_col: 'Score',
|