Skip to content

Commit d5bb4fd

Browse files
author
brett-bonner_infodesk
committed
fix(example): reset index on sorted living-app DataFrame
The JSON pandas preflight requires a default RangeIndex; sort_values().head() keeps original row labels.
1 parent e4ba95e commit d5bb4fd

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

  • examples/living-app/living_app

examples/living-app/living_app/app.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,4 +364,11 @@ def top_users_by_spend(path: str, top_n: int = 10) -> pd.DataFrame:
364364
cols = [c for c in cols if c in df.columns]
365365
if "spend_usd_last_7d" not in df.columns:
366366
return df[cols].head(top_n)
367-
return df[cols].sort_values("spend_usd_last_7d", ascending=False).head(top_n)
367+
# The JSON codec requires a default RangeIndex; sort_values().head() keeps
368+
# the original row labels, so drop them.
369+
return (
370+
df[cols]
371+
.sort_values("spend_usd_last_7d", ascending=False)
372+
.head(top_n)
373+
.reset_index(drop=True)
374+
)

0 commit comments

Comments
 (0)