-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
DOC: Improve the docstring of pandas.core.window.Rolling.median #20260
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 5 commits
2032776
afb9515
ad3572c
6a1106a
80ce2fc
6280b68
6ee9acd
1794aca
702abc4
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 |
---|---|---|
|
@@ -850,7 +850,41 @@ def mean(self, *args, **kwargs): | |
return self._apply('roll_mean', 'mean', **kwargs) | ||
|
||
_shared_docs['median'] = dedent(""" | ||
%(name)s median | ||
Calculate the %(name)s median. | ||
|
||
Parameters | ||
---------- | ||
**kwargs | ||
Under Review. | ||
|
||
Returns | ||
------- | ||
Series or DataFrame | ||
Returned object type is determined by the caller of the %(name)s | ||
object. | ||
|
||
See Also | ||
-------- | ||
Series.%(name)s : Calling object with Series data | ||
DataFrame.%(name)s : Calling object with DataFrames | ||
Series.median : Equivalent method for Series | ||
DataFrame.median : Equivalent method for DataFrame | ||
|
||
Examples | ||
-------- | ||
The below example will show a rolling calculation with a window size of | ||
three. | ||
|
||
>>> import pandas as pd | ||
>>> import numpy as np | ||
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. Import pandas and numpy is not necessary in the examples. 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. Good to know. I've removed them. |
||
>>> s = pd.Series(np.arange(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. Perhaps construct the series manually to avoid the reader having to think about arange:
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. That make sense. I've changed it from |
||
>>> s.rolling(3).median() | ||
0 NaN | ||
1 NaN | ||
2 1.0 | ||
3 2.0 | ||
4 3.0 | ||
dtype: float64 | ||
""") | ||
|
||
def median(self, **kwargs): | ||
|
@@ -1244,7 +1278,6 @@ def mean(self, *args, **kwargs): | |
return super(Rolling, self).mean(*args, **kwargs) | ||
|
||
@Substitution(name='rolling') | ||
@Appender(_doc_template) | ||
@Appender(_shared_docs['median']) | ||
def median(self, **kwargs): | ||
return super(Rolling, self).median(**kwargs) | ||
|
@@ -1483,7 +1516,6 @@ def mean(self, *args, **kwargs): | |
return super(Expanding, self).mean(*args, **kwargs) | ||
|
||
@Substitution(name='expanding') | ||
@Appender(_doc_template) | ||
@Appender(_shared_docs['median']) | ||
def median(self, **kwargs): | ||
return super(Expanding, self).median(**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.
I'd be more direct and say "Compute the rolling mean of a series with a window size of 3:".
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.
I agree... but this is median. Copy paste has failed me!
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.
Ah yes median, sorry.