Skip to content
Merged
Changes from 1 commit
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
45 changes: 41 additions & 4 deletions pandas/core/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,47 @@ 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 example 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()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add a blank line between cases

0 NaN
1 NaN
2 2.0
3 3.0
dtype: float64
""")


class Window(_Window):
Expand Down Expand Up @@ -646,7 +686,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 +1276,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 +1514,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