Applications of Rolling Windows for Time Series, with Python

Author:Murphy  |  View: 21621  |  Time: 2025-03-23 11:25:26

Last night I was doing laundry with my wife. We have this non-verbal agreement (it becomes pretty verbal when I break it though) about laundry: she is the one who puts the laundry in the washer and drier and I am the one who folds it.

The way we do this is usually like this:

Image made by author using DALLE

Now, I don't really fold all the clothes and put them away. Otherwise, I would be swimming in clothes. What I do is an approach that reminds me of the rolling window method:

Image made by author using DALLE

Why do I say that it reminds me of a rolling window? Let's see the analogy.

Image made by author using DALLE

The idea of rolling windows is exactly the one that I apply when folding laundry. I have a task to do but you don't do it all at once, because it would be nonpractical and not useful. Instead, I do it on a small portion of "data", then store the "result", and then move to the next section of "data".

This idea looks very simple, but there are SO MANY things you can do with Rolling Windows, as this very simple approach is also incredibly powerful.

In this blog post, I want to describe very briefly what rolling windows are on a technical level, then show a few powerful applications of rolling windows on some specific tasks that are often required when dealing with a signal.

We will do this in the following order:

  1. A technical introduction about the rolling windows idea
  2. We'll use rolling windows as feature extractors (first use case)
  3. We'll use rolling windows as a smoother/noise reducer (second use case)
  4. We'll use rolling windows to extract peaks and valleys of a signal (third use case)
  5. We'll use rolling windows to perform a Fourier Transform (fourth use case)

A lot to cover, better get started!

Tags: Data Science Hands On Tutorials Machine Learning Python Timeseries

Comment