Skip to content
skillbld
Day 11 of 14 35 minrolling()shift()pct_change()

Analyse how numbers change over time. Use a date index, smooth noisy data with rolling averages, compare each period with the one before using shift() and diff(), measure growth with pct_change(), and build running totals.

By the end of today you can

  • Set up a DataFrame with a DatetimeIndex and select date ranges
  • Smooth daily noise with rolling() averages
  • Compare periods with shift() and diff()
  • Measure growth with pct_change(), including month over month and year over year
  • Build running totals with cumsum() and running maximums with cummax()

What's inside

  • 6 sections
  • 3 diagrams and mind maps
  • 6 code examples you can run
  • 5-question quiz
  1. 1A date index
  2. 2rolling(): smooth out the noise
  3. 3shift() and diff(): compare with the previous period
  4. 4pct_change(): growth rates
  5. 5Running totals: cumsum() and cummax()
  6. 6Putting it together: resample, then compare

Sign in free to read this lesson

Get the full lesson with diagrams, runnable code and the quiz. Your progress is saved across devices.

Sign in free
Day 11: Time-Series Analysis · Data Analysis with pandas · SkillBld