pandas.core.window.rolling.Window.var
- Window.var(ddof=1, numeric_only=False, **kwargs)
Calculate the rolling weighted window variance.
- Parameters:
- numeric_only : bool, default False
Include only float, int, boolean columns.
Calculate the rolling weighted window variance.
Include only float, int, boolean columns.
Added in version 1.5.0.
Keyword arguments to configure the SciPy weighted window type.
Return type is the same as the original object with np.float64 dtype.
>>> ser = pd.Series([0, 1, 5, 2, 8])
To get an instance of Window we need
to pass the parameter win_type.
>>> type(ser.rolling(2, win_type='gaussian'))
<class 'pandas.core.window.rolling.Window'>
In order to use the SciPy Gaussian window we need to provide the parameters M and std. The parameter M corresponds to 2 in our example. We pass the second parameter std as a parameter of the following method:
>>> ser.rolling(2, win_type='gaussian').var(std=3)
0 NaN
1 0.5
2 8.0
3 4.5
4 18.0
dtype: float64