pandas and NumPy 3 · Grouping and combining

Compute a moving average

Average over a sliding window of seven rows.

df["avg_7"] = df["sales"].rolling(7).mean()

Official pandas and NumPy 3 documentation

More grouping and combining commands

All grouping and combining commands · pandas and NumPy 3 cheatsheet

Was this page helpful?