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 |
.rolling().mean() |
The mean of values in the window |
.rolling().std() |
The standard deviation of values in the window |
.rolling... |