Data Science

Time Series Resampling

Senior Data Analyst
April 23, 2026
5 min read

Resampling

df.set_index('order_date', inplace=True)

# Monthly sum

monthly = df['sales'].resample('M').sum()

# Weekly average

weekly = df['sales'].resample('W').mean()

Common Frequency Codes

  • `D`: Daily
  • `W`: Weekly
  • `M`: Monthly
  • `Q`: Quarterly
  • `Y`: Yearly
  • *Day 114: String Operations in Pandas.*

    Ready to put your knowledge into practice?

    Join SQL Mastery and learn through interactive exercises.