Time-series moving-window operations

pandas provides a number of functions to compute moving (also known as rolling) statistics. In a rolling window, pandas computes the statistic on a window of data represented by a particular period of time. The window is then rolled along a certain interval, and the statistic is continually calculated on each window as long as the window fits within the dates of the time series.

pandas provides direct support for rolling windows by providing a .rolling() method on the Series and DataFrame objects. The resulting value from .rolling() can then have one of many different methods called which perform the calculation on each window. The following table shows a number of these methods:

Function

Description ...

Get Learning pandas - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.