pandas.core.window.rolling.Window.std¶
-
Window.
std
(ddof=1, *args, **kwargs)[source]¶ Calculate window standard deviation.
New in version 1.0.0.
Normalized by N-1 by default. This can be changed using the ddof argument.
- Parameters
- ddofint, default 1
Delta Degrees of Freedom. The divisor used in calculations is
N - ddof
, whereN
represents the number of elements.- *args, **kwargs
For NumPy compatibility. No additional arguments are used.
- Returns
- Series or DataFrame
Returns the same object type as the caller of the window calculation.
See also
pandas.Series.window
Calling object with Series data.
pandas.DataFrame.window
Calling object with DataFrames.
pandas.Series.std
Equivalent method for Series.
pandas.DataFrame.std
Equivalent method for DataFrame.
numpy.std
Equivalent method for Numpy array.
Notes
The default ddof of 1 used in Series.std is different than the default ddof of 0 in numpy.std.
A minimum of one period is required for the rolling calculation.
Examples
>>> s = pd.Series([5, 5, 6, 7, 5, 5, 5]) >>> s.rolling(3).std() 0 NaN 1 NaN 2 0.577350 3 1.000000 4 1.000000 5 1.154701 6 0.000000 dtype: float64
>>> s.expanding(3).std() 0 NaN 1 NaN 2 0.577350 3 0.957427 4 0.894427 5 0.836660 6 0.786796 dtype: float64