sum¶
-
sum_
(x, w=Window(w=None, r=0))[source]¶ Rolling sum of series over given window
- Parameters
x (
Series
) – series: timeseriesw (
Union
[Window
,int
]) – Window or int: number of observations and ramp up to use. e.g. Window(22, 10) where 22 is the window size
and 10 the ramp up value. Window size defaults to length of series. :rtype:
Series
:return: timeseries of rolling sumUsage
Calculate the sum of observations over a given rolling window. For each time, \(t\), returns the value of all observations from \(t-w+1\) to \(t\) summed together:
\(R_t = \sum_{i=t-w+1}^{t} X_i\)
where \(w\) is the size of the rolling window. If window is not provided, computes sum over the full series
Examples
Generate price series and compute rolling sum over \(22\) observations
>>> prices = generate_series(100) >>> sum_(prices, 22)
See also