Skip to content
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

DOC: update the pandas.core.window.x.mean docstring #20265

Merged
merged 3 commits into from
Mar 17, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 42 additions & 4 deletions pandas/core/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,48 @@ def aggregate(self, arg, *args, **kwargs):
%(name)s sum""")

_shared_docs['mean'] = dedent("""
%(name)s mean""")
Calculate the %(name)s mean of the values.

Parameters
----------
*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.mean : Equivalent method for Series
DataFrame.mean : Equivalent method for DataFrame

Examples
--------
The below examples will show rolling mean calculations with window sizes of
two and three, respectively.

>>> s = pd.Series([1, 2, 3, 4])
>>> s.rolling(2).mean()
0 NaN
1 1.5
2 2.5
3 3.5
dtype: float64

>>> s.rolling(3).mean()
0 NaN
1 NaN
2 2.0
3 3.0
dtype: float64
""")


class Window(_Window):
Expand Down Expand Up @@ -646,7 +687,6 @@ def sum(self, *args, **kwargs):
return self._apply_window(mean=False, **kwargs)

@Substitution(name='window')
@Appender(_doc_template)
@Appender(_shared_docs['mean'])
def mean(self, *args, **kwargs):
nv.validate_window_func('mean', args, kwargs)
Expand Down Expand Up @@ -1237,7 +1277,6 @@ def min(self, *args, **kwargs):
return super(Rolling, self).min(*args, **kwargs)

@Substitution(name='rolling')
@Appender(_doc_template)
@Appender(_shared_docs['mean'])
def mean(self, *args, **kwargs):
nv.validate_rolling_func('mean', args, kwargs)
Expand Down Expand Up @@ -1476,7 +1515,6 @@ def min(self, *args, **kwargs):
return super(Expanding, self).min(*args, **kwargs)

@Substitution(name='expanding')
@Appender(_doc_template)
@Appender(_shared_docs['mean'])
def mean(self, *args, **kwargs):
nv.validate_expanding_func('mean', args, kwargs)
Expand Down