# pandas.core.window.Rolling.std¶

Calculate rolling standard deviation.

Normalized by N-1 by default. This can be changed using the ddof argument.

param ddof
int, default 1

Delta Degrees of Freedom. The divisor used in calculations is N - ddof, where N represents the number of elements. *args, **kwargs For NumPy compatibility. No additional arguments are used.

return

Series or DataFrame Returns the same object type as the caller of the rolling calculation.

## Limitations¶

DataFrame/Series elements cannot be max/min float/integer. Otherwise SDC and Pandas results are different.

## Examples¶

Calculate rolling standard deviation.
import pandas as pd
from numba import njit

@njit
def series_rolling_std():
series = pd.Series([4, 3, 5, 2, 6])  # Series of 4, 3, 5, 2, 6
out_series = series.rolling(3).std()

return out_series  # Expect series of NaN, NaN, 1.000000, 1.527525, 2.081666

print(series_rolling_std())

$python ./series/rolling/series_rolling_std.py 0 NaN 1 NaN 2 1.000000 3 1.527525 4 2.081666 dtype: float64  Calculate rolling standard deviation. import pandas as pd from numba import njit @njit def df_rolling_std(): df = pd.DataFrame({'A': [4, 3, 5, 2, 6], 'B': [-4, -3, -5, -2, -6]}) out_df = df.rolling(3).std() # Expect DataFrame of # {'A': [NaN, NaN, 1.000000, 1.527525, 2.081666], # 'B': [NaN, NaN, 1.000000, 1.527525, 2.081666]} return out_df print(df_rolling_std())  $ python ./dataframe/rolling/dataframe_rolling_std.py
A         B
0       NaN       NaN
1       NaN       NaN
2  1.000000  1.000000
3  1.527525  1.527525
4  2.081666  2.081666


Series.rolling

Calling object with a Series.

DataFrame.rolling

Calling object with a DataFrame.

Series.std

Similar method for Series.

DataFrame.std

Similar method for DataFrame.