product¶
-
product
(x, w=Window(w=None, r=0))[source]¶ Rolling product 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 productUsage
Calculate the product of observations over a given rolling window. For each time, \(t\), returns the value of all observations from \(t-w+1\) to \(t\) multiplied together:
\(R_t = \prod_{i=t-w+1}^{t} X_i\)
where \(w\) is the size of the rolling window. If window is not provided, computes product over the full series
Examples
Generate price series and compute rolling sum over \(22\) observations
>>> prices = generate_series(100) >>> product(1+returns(prices))
See also