Skip to content

Commit ad50b1d

Browse files
johnnymetzjorisvandenbossche
authored andcommitted
DOC: update the pandas.core.window.x.mean docstring (#20265)
1 parent eb1f51f commit ad50b1d

File tree

1 file changed

+42
-4
lines changed

1 file changed

+42
-4
lines changed

pandas/core/window.py

+42-4
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,48 @@ def aggregate(self, arg, *args, **kwargs):
395395
""")
396396

397397
_shared_docs['mean'] = dedent("""
398-
%(name)s mean""")
398+
Calculate the %(name)s mean of the values.
399+
400+
Parameters
401+
----------
402+
*args
403+
Under Review.
404+
**kwargs
405+
Under Review.
406+
407+
Returns
408+
-------
409+
Series or DataFrame
410+
Returned object type is determined by the caller of the %(name)s
411+
calculation.
412+
413+
See Also
414+
--------
415+
Series.%(name)s : Calling object with Series data
416+
DataFrame.%(name)s : Calling object with DataFrames
417+
Series.mean : Equivalent method for Series
418+
DataFrame.mean : Equivalent method for DataFrame
419+
420+
Examples
421+
--------
422+
The below examples will show rolling mean calculations with window sizes of
423+
two and three, respectively.
424+
425+
>>> s = pd.Series([1, 2, 3, 4])
426+
>>> s.rolling(2).mean()
427+
0 NaN
428+
1 1.5
429+
2 2.5
430+
3 3.5
431+
dtype: float64
432+
433+
>>> s.rolling(3).mean()
434+
0 NaN
435+
1 NaN
436+
2 2.0
437+
3 3.0
438+
dtype: float64
439+
""")
399440

400441

401442
class Window(_Window):
@@ -718,7 +759,6 @@ def sum(self, *args, **kwargs):
718759
return self._apply_window(mean=False, **kwargs)
719760

720761
@Substitution(name='window')
721-
@Appender(_doc_template)
722762
@Appender(_shared_docs['mean'])
723763
def mean(self, *args, **kwargs):
724764
nv.validate_window_func('mean', args, kwargs)
@@ -1447,7 +1487,6 @@ def min(self, *args, **kwargs):
14471487
return super(Rolling, self).min(*args, **kwargs)
14481488

14491489
@Substitution(name='rolling')
1450-
@Appender(_doc_template)
14511490
@Appender(_shared_docs['mean'])
14521491
def mean(self, *args, **kwargs):
14531492
nv.validate_rolling_func('mean', args, kwargs)
@@ -1707,7 +1746,6 @@ def min(self, *args, **kwargs):
17071746
return super(Expanding, self).min(*args, **kwargs)
17081747

17091748
@Substitution(name='expanding')
1710-
@Appender(_doc_template)
17111749
@Appender(_shared_docs['mean'])
17121750
def mean(self, *args, **kwargs):
17131751
nv.validate_expanding_func('mean', args, kwargs)

0 commit comments

Comments
 (0)