pandas.api.typing.Window.std#

Window.std(ddof=1, numeric_only=False, **kwargs)[source]#

Calculate the rolling weighted window standard deviation.

The window type is determined by the win_type parameter specified in DataFrame.rolling() or Series.rolling(). Additional keyword arguments are passed to the SciPy window function.

Parameters:
ddofint, default 1

Delta Degrees of Freedom. The divisor used in calculations is N - ddof, where N represents the number of elements.

numeric_onlybool, default False

Include only float, int, boolean columns.

**kwargs

Keyword arguments to configure the SciPy weighted window type.

Returns:
Series or DataFrame

Return type is the same as the original object with np.float64 dtype.

See also

Series.rolling

Calling rolling with Series data.

DataFrame.rolling

Calling rolling with DataFrames.

Series.std

Aggregating std for Series.

DataFrame.std

Aggregating std for DataFrame.

Examples

>>> 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.api.typing.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").std(std=3)
0         NaN
1    0.707107
2    2.828427
3    2.121320
4    4.242641
dtype: float64