Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -115,20 +115,15 @@ def colour_method(name: str) -> str:
|
|
115 |
# darkest → lightest
|
116 |
TOP5_GREENS = ["#006400", "#228B22", "#32CD32", "#7CFC00", "#ADFF2F"]
|
117 |
|
118 |
-
def
|
119 |
-
"""Return
|
120 |
-
# ignore non-numeric cols
|
121 |
if not pd.api.types.is_numeric_dtype(col):
|
122 |
-
return [""] * len(col)
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
styles.append(f"background-color:{TOP5_GREENS[int(r)-1]};")
|
129 |
-
else:
|
130 |
-
styles.append("")
|
131 |
-
return styles
|
132 |
|
133 |
def make_leaderboard_df(selected_methods=None, selected_metrics=None):
|
134 |
"""Fetch, tidy, colour, and return a Styler that Gradio will render."""
|
|
|
115 |
# darkest → lightest
|
116 |
TOP5_GREENS = ["#006400", "#228B22", "#32CD32", "#7CFC00", "#ADFF2F"]
|
117 |
|
118 |
+
def shade_top5(col: pd.Series) -> list[str]:
|
119 |
+
"""Return background‐colour CSS for the best 5 numeric cells of a column."""
|
|
|
120 |
if not pd.api.types.is_numeric_dtype(col):
|
121 |
+
return [""] * len(col) # leave non-numeric cols untouched
|
122 |
+
ranks = col.rank(ascending=False, method="first")
|
123 |
+
return [
|
124 |
+
f"background-color:{TOP5_GREENS[int(r)-1]};" if r <= 5 else ""
|
125 |
+
for r in ranks
|
126 |
+
]
|
|
|
|
|
|
|
|
|
127 |
|
128 |
def make_leaderboard_df(selected_methods=None, selected_metrics=None):
|
129 |
"""Fetch, tidy, colour, and return a Styler that Gradio will render."""
|