Spaces:
Sleeping
Sleeping
Zen0
commited on
Commit
Β·
b124e72
1
Parent(s):
fc15652
Fix ranking medals: handle fewer than 3 models
Browse filesValueError when trying to assign 3 medals to 1 result.
Fixed logic to only assign medals up to number of results.
Before: ['π₯', 'π₯', 'π₯'] + [''] * (len(df) - 3) # Fails with 1 model
After: medals[:len(df)] + [''] * max(0, len(df) - len(medals)) # Works with any count
app.py
CHANGED
|
@@ -385,7 +385,12 @@ def format_results_table(results):
|
|
| 385 |
# Sort by accuracy and assign ranks
|
| 386 |
df['_sort'] = df['Accuracy'].str.replace('%', '').astype(float)
|
| 387 |
df = df.sort_values('_sort', ascending=False)
|
| 388 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 389 |
df = df.drop('_sort', axis=1)
|
| 390 |
|
| 391 |
return df
|
|
|
|
| 385 |
# Sort by accuracy and assign ranks
|
| 386 |
df['_sort'] = df['Accuracy'].str.replace('%', '').astype(float)
|
| 387 |
df = df.sort_values('_sort', ascending=False)
|
| 388 |
+
|
| 389 |
+
# Assign medals (handle cases with fewer than 3 models)
|
| 390 |
+
medals = ['π₯', 'π₯', 'π₯']
|
| 391 |
+
ranks = medals[:len(df)] + [''] * max(0, len(df) - len(medals))
|
| 392 |
+
df['Rank'] = ranks
|
| 393 |
+
|
| 394 |
df = df.drop('_sort', axis=1)
|
| 395 |
|
| 396 |
return df
|