@@ -857,13 +857,62 @@ def median(self, **kwargs):
857
857
return self ._apply ('roll_median_c' , 'median' , ** kwargs )
858
858
859
859
_shared_docs ['std' ] = dedent ("""
860
- %(name)s standard deviation
860
+ Calculate %(name)s standard deviation.
861
+
862
+ Normalized by N-1 by default. This can be changed using the `ddof`
863
+ argument.
861
864
862
865
Parameters
863
866
----------
864
867
ddof : int, default 1
865
868
Delta Degrees of Freedom. The divisor used in calculations
866
- is ``N - ddof``, where ``N`` represents the number of elements.""" )
869
+ is ``N - ddof``, where ``N`` represents the number of elements.
870
+ *args, **kwargs
871
+ For NumPy compatibility. No additional arguments are used.
872
+
873
+ Returns
874
+ -------
875
+ Series or DataFrame
876
+ Returns the same object type as the caller of the %(name)s calculation.
877
+
878
+ See Also
879
+ --------
880
+ Series.%(name)s : Calling object with Series data
881
+ DataFrame.%(name)s : Calling object with DataFrames
882
+ Series.std : Equivalent method for Series
883
+ DataFrame.std : Equivalent method for DataFrame
884
+ numpy.std : Equivalent method for Numpy array
885
+
886
+ Notes
887
+ -----
888
+ The default `ddof` of 1 used in Series.std is different than the default
889
+ `ddof` of 0 in numpy.std.
890
+
891
+ A minimum of one period is required for the rolling calculation.
892
+
893
+ Examples
894
+ --------
895
+ >>> s = pd.Series([5, 5, 6, 7, 5, 5, 5])
896
+ >>> s.rolling(3).std()
897
+ 0 NaN
898
+ 1 NaN
899
+ 2 0.577350
900
+ 3 1.000000
901
+ 4 1.000000
902
+ 5 1.154701
903
+ 6 0.000000
904
+ dtype: float64
905
+
906
+ >>> s.expanding(3).std()
907
+ 0 NaN
908
+ 1 NaN
909
+ 2 0.577350
910
+ 3 0.957427
911
+ 4 0.894427
912
+ 5 0.836660
913
+ 6 0.786796
914
+ dtype: float64
915
+ """ )
867
916
868
917
def std (self , ddof = 1 , * args , ** kwargs ):
869
918
nv .validate_window_func ('std' , args , kwargs )
@@ -1229,7 +1278,6 @@ def median(self, **kwargs):
1229
1278
return super (Rolling , self ).median (** kwargs )
1230
1279
1231
1280
@Substitution (name = 'rolling' )
1232
- @Appender (_doc_template )
1233
1281
@Appender (_shared_docs ['std' ])
1234
1282
def std (self , ddof = 1 , * args , ** kwargs ):
1235
1283
nv .validate_rolling_func ('std' , args , kwargs )
@@ -1493,7 +1541,6 @@ def median(self, **kwargs):
1493
1541
return super (Expanding , self ).median (** kwargs )
1494
1542
1495
1543
@Substitution (name = 'expanding' )
1496
- @Appender (_doc_template )
1497
1544
@Appender (_shared_docs ['std' ])
1498
1545
def std (self , ddof = 1 , * args , ** kwargs ):
1499
1546
nv .validate_expanding_func ('std' , args , kwargs )
0 commit comments