Moving windows

A number of functions are provided to compute moving (also known as rolling) statistics, where the function computes the statistic on a window of data represented by a particular period of time and then slides the window across the data by a specified interval, continually calculating the statistic as long as the window falls first within the dates of the time-series.

With the following functions, pandas provides direct support for rolling windows:

Function

Description

rolling_mean

This is the mean of the values in the window

rolling_std

This is the standard deviation of the values in the window

rolling_var

This is the variance of values

rolling_min

This is the minimum of the values in the window

rolling_max

Get Mastering pandas for Finance 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.