Course contentsShow
← Machine Learning and Deep Learning
Lesson 2394 of 3,53852. Time Series and ForecastingFree lesson

Resampling and Frequency Conversion

Upsampling and downsampling time series; aggregation functions for converting between different temporal resolutions.

Resampling and Frequency Conversion

What you'll learn: How to change the temporal resolution of time series data by upsampling (increasing frequency) or downsampling (decreasing frequency) to match analytical needs.

The Core Idea

Time series data often arrives at one frequency (hourly, daily, etc.) but you need to analyze it at another. Resampling is the process of converting data from one temporal resolution to another—like converting hourly temperature readings into daily averages, or filling in monthly sales data to get weekly estimates.

Think of it like adjusting the zoom level on a map: downsampling zooms out (showing less detail but broader patterns), while upsampling zooms in (requiring you to fill in missing details).

Downsampling: From High to Low Frequency

When you downsample (e.g., hourly → daily), you compress multiple observations into one. This requires choosing an aggregation function:

  • sum() - Total sales per week from daily values
  • mean() - Average temperature per month from hourly readings
  • max() / min() - Peak values in each period
  • last() / first() - Opening/closing prices for financial data

The choice depends on what the data represents. Revenue should be summed; temperature should be averaged.

Upsampling: From Low to High Frequency

Upsampling (e.g., monthly → weekly) creates new time points where no data existed. You must specify a fill method:

  • Forward fill: Repeat the last known value
  • Backward fill: Use the next known value
  • Interpolation: Estimate intermediate values (though this goes beyond basic frequency conversion)

Why This Matters

Different forecasting models work best at different frequencies. You might aggregate noisy daily data into weekly buckets to reveal clearer trends, or upsample sparse monthly data to align with other daily features in your model.

Key Takeaway: Resampling adjusts time series frequency through downsampling (with aggregation functions like sum or mean) or upsampling (with filling strategies), enabling you to match data granularity to your analytical requirements.