O'Reilly logo

Learning pandas - Second Edition by Michael Heydt

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Performing moving-window operations

Pandas provides a number of functions to compute moving (also known as rolling) statistics. A rolling window computes the specified statistic on a specified interval of data. The window is then moved along the data by a specific interval and recalculated. The process continues until the window has been rolled across the entire dataset.

To demonstrate this, we will start with a series of 1000 random numbers that are cumulatively summed to form a random walk:

Zooming in on the first 100 values, we can see the movement of the data with the following plot:

To start creating a rolling window, we create a Rolling ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required