Skip to content

Commit e7e0ea8

Browse files
mehemkenTomAugspurger
authored andcommitted
DOC: Improve the docstring of pandas.core.window.Rolling.median (#20260)
1 parent b547454 commit e7e0ea8

File tree

1 file changed

+32
-3
lines changed

1 file changed

+32
-3
lines changed

pandas/core/window.py

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,38 @@ def mean(self, *args, **kwargs):
850850
return self._apply('roll_mean', 'mean', **kwargs)
851851

852852
_shared_docs['median'] = dedent("""
853-
%(name)s median
853+
Calculate the %(name)s median.
854+
855+
Parameters
856+
----------
857+
**kwargs
858+
For compatibility with other %(name)s methods. Has no effect
859+
on the computed median.
860+
861+
Returns
862+
-------
863+
Series or DataFrame
864+
Returned type is the same as the original object.
865+
866+
See Also
867+
--------
868+
Series.%(name)s : Calling object with Series data
869+
DataFrame.%(name)s : Calling object with DataFrames
870+
Series.median : Equivalent method for Series
871+
DataFrame.median : Equivalent method for DataFrame
872+
873+
Examples
874+
--------
875+
Compute the rolling median of a series with a window size of 3.
876+
877+
>>> s = pd.Series([0, 1, 2, 3, 4])
878+
>>> s.rolling(3).median()
879+
0 NaN
880+
1 NaN
881+
2 1.0
882+
3 2.0
883+
4 3.0
884+
dtype: float64
854885
""")
855886

856887
def median(self, **kwargs):
@@ -1321,7 +1352,6 @@ def mean(self, *args, **kwargs):
13211352
return super(Rolling, self).mean(*args, **kwargs)
13221353

13231354
@Substitution(name='rolling')
1324-
@Appender(_doc_template)
13251355
@Appender(_shared_docs['median'])
13261356
def median(self, **kwargs):
13271357
return super(Rolling, self).median(**kwargs)
@@ -1583,7 +1613,6 @@ def mean(self, *args, **kwargs):
15831613
return super(Expanding, self).mean(*args, **kwargs)
15841614

15851615
@Substitution(name='expanding')
1586-
@Appender(_doc_template)
15871616
@Appender(_shared_docs['median'])
15881617
def median(self, **kwargs):
15891618
return super(Expanding, self).median(**kwargs)

0 commit comments

Comments
 (0)