Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Fix wrapping to keep non-str data
Browse files- src/details.py +9 -1
src/details.py
CHANGED
|
@@ -68,7 +68,15 @@ def display_details(sample_idx, *dfs):
|
|
| 68 |
# Pop model_name and add it to the column name
|
| 69 |
df = pd.concat([row.rename(row.pop("model_name")) for row in rows], axis="columns")
|
| 70 |
# Wrap long strings to avoid overflow; e.g. URLs in "doc.Websites visited_NEV_2"
|
| 71 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
return (
|
| 73 |
df.style
|
| 74 |
.format(escape="html", na_rep="")
|
|
|
|
| 68 |
# Pop model_name and add it to the column name
|
| 69 |
df = pd.concat([row.rename(row.pop("model_name")) for row in rows], axis="columns")
|
| 70 |
# Wrap long strings to avoid overflow; e.g. URLs in "doc.Websites visited_NEV_2"
|
| 71 |
+
def wrap(row):
|
| 72 |
+
try:
|
| 73 |
+
result = row.str.wrap(140)
|
| 74 |
+
return result if result.notna().all() else row # NaN when data is a list
|
| 75 |
+
except AttributeError: # when data is number
|
| 76 |
+
return row
|
| 77 |
+
|
| 78 |
+
df = df.apply(wrap, axis=1)
|
| 79 |
+
# Style
|
| 80 |
return (
|
| 81 |
df.style
|
| 82 |
.format(escape="html", na_rep="")
|