-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
DOC: update Rolling.std docstring #20235
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -857,13 +857,58 @@ def median(self, **kwargs): | |
return self._apply('roll_median_c', 'median', **kwargs) | ||
|
||
_shared_docs['std'] = dedent(""" | ||
%(name)s standard deviation | ||
Calculate %(name)s standard deviation. | ||
|
||
Normalized by N-1 by default. This can be changed using the ddof argument. | ||
|
||
Parameters | ||
---------- | ||
ddof : int, default 1 | ||
Delta Degrees of Freedom. The divisor used in calculations | ||
is ``N - ddof``, where ``N`` represents the number of elements.""") | ||
is ``N - ddof``, where ``N`` represents the number of elements. | ||
args | ||
Under Review. | ||
kwargs | ||
Under Review. | ||
|
||
Returns | ||
------- | ||
Series or DataFrame | ||
Returned object type is determined by the caller of the %(name)s | ||
calculation | ||
|
||
See Also | ||
-------- | ||
Series.%(name)s : Calling object with Series data | ||
DataFrame.%(name)s : Calling object with DataFrames | ||
Series.std : Equivalent method for Series | ||
DataFrame.std : Equivalent method for DataFrame | ||
numpy.std : Equivalent method for Numpy array | ||
|
||
Notes | ||
----- | ||
A minimum of 1 periods is required for the rolling calculation. | ||
|
||
Examples | ||
-------- | ||
The below example will show a rolling example | ||
|
||
>>> s = pd.Series((5,5,5,5,6,7,9,10,5,5,5,5)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you make this PEP8: spaces after the comma. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you address the second part of the comment as well? |
||
>>> s.rolling(3).std(1) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if you use the default, I would leave out the |
||
0 NaN | ||
1 NaN | ||
2 0.000000 | ||
3 0.000000 | ||
4 0.577350 | ||
5 1.000000 | ||
6 1.527525 | ||
7 1.527525 | ||
8 2.645751 | ||
9 2.886751 | ||
10 0.000000 | ||
11 0.000000 | ||
dtype: float64 | ||
""") | ||
|
||
def std(self, ddof=1, *args, **kwargs): | ||
nv.validate_window_func('std', args, kwargs) | ||
|
@@ -1250,7 +1295,6 @@ def median(self, **kwargs): | |
return super(Rolling, self).median(**kwargs) | ||
|
||
@Substitution(name='rolling') | ||
@Appender(_doc_template) | ||
@Appender(_shared_docs['std']) | ||
def std(self, ddof=1, *args, **kwargs): | ||
nv.validate_rolling_func('std', args, kwargs) | ||
|
@@ -1489,7 +1533,6 @@ def median(self, **kwargs): | |
return super(Expanding, self).median(**kwargs) | ||
|
||
@Substitution(name='expanding') | ||
@Appender(_doc_template) | ||
@Appender(_shared_docs['std']) | ||
def std(self, ddof=1, *args, **kwargs): | ||
nv.validate_expanding_func('std', args, kwargs) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you put single backticks around ddof (like
`ddof`
) (because it is a parameter name)