pandas and NumPy 3 · Grouping and combining

Aggregate by time period

Sum values by month. The index must be a datetime.

df.set_index("date")["sales"].resample("MS").sum()

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?