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
- Group and aggregate
- Create a pivot table
- Join two DataFrames
- Stack DataFrames
- Aggregate by time period
- Save to a CSV file
All grouping and combining commands · pandas and NumPy 3 cheatsheet