Skip to content

Commit 3f2f01e

Browse files
LJArendsePingviinituutti
authored andcommitted
DOC: Fix docstring of window.Expanding/Rolling.apply and document *args and **kwargs (pandas-dev#24184)
1 parent 4af752e commit 3f2f01e

File tree

1 file changed

+44
-11
lines changed

1 file changed

+44
-11
lines changed

pandas/core/window.py

+44-11
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,13 @@
3232
_doc_template = """
3333
Returns
3434
-------
35-
same type as input
35+
Series or DataFrame
36+
Return type is determined by the caller.
3637
3738
See Also
3839
--------
39-
Series.%(name)s
40-
DataFrame.%(name)s
40+
Series.%(name)s : Series %(name)s.
41+
DataFrame.%(name)s : DataFrame %(name)s.
4142
"""
4243

4344

@@ -946,13 +947,13 @@ def count(self):
946947
return self._wrap_results(results, blocks, obj)
947948

948949
_shared_docs['apply'] = dedent(r"""
949-
%(name)s function apply.
950+
The %(name)s function's apply function.
950951
951952
Parameters
952953
----------
953954
func : function
954955
Must produce a single value from an ndarray input if ``raw=True``
955-
or a Series if ``raw=False``
956+
or a Series if ``raw=False``.
956957
raw : bool, default None
957958
* ``False`` : passes each row or column as a Series to the
958959
function.
@@ -965,8 +966,19 @@ def count(self):
965966
not passed. In the future `raw` will default to False.
966967
967968
.. versionadded:: 0.23.0
969+
*args, **kwargs
970+
Arguments and keyword arguments to be passed into func.
968971
969-
\*args and \*\*kwargs are passed to the function""")
972+
Returns
973+
-------
974+
Series or DataFrame
975+
Return type is determined by the caller.
976+
977+
See Also
978+
--------
979+
Series.%(name)s : Series %(name)s.
980+
DataFrame.%(name)s : DataFrame %(name)s.
981+
""")
970982

971983
def apply(self, func, raw=None, args=(), kwargs={}):
972984
from pandas import Series
@@ -1005,6 +1017,11 @@ def sum(self, *args, **kwargs):
10051017

10061018
_shared_docs['max'] = dedent("""
10071019
Calculate the %(name)s maximum.
1020+
1021+
Parameters
1022+
----------
1023+
*args, **kwargs
1024+
Arguments and keyword arguments to be passed into func.
10081025
""")
10091026

10101027
def max(self, *args, **kwargs):
@@ -1227,7 +1244,14 @@ def var(self, ddof=1, *args, **kwargs):
12271244
check_minp=_require_min_periods(1), ddof=ddof,
12281245
**kwargs)
12291246

1230-
_shared_docs['skew'] = """Unbiased %(name)s skewness"""
1247+
_shared_docs['skew'] = """
1248+
Unbiased %(name)s skewness.
1249+
1250+
Parameters
1251+
----------
1252+
**kwargs
1253+
Keyword arguments to be passed into func.
1254+
"""
12311255

12321256
def skew(self, **kwargs):
12331257
return self._apply('roll_skew', 'skew',
@@ -1359,6 +1383,8 @@ def f(arg, *args, **kwargs):
13591383
ddof : int, default 1
13601384
Delta Degrees of Freedom. The divisor used in calculations
13611385
is ``N - ddof``, where ``N`` represents the number of elements.
1386+
**kwargs
1387+
Keyword arguments to be passed into func.
13621388
"""
13631389

13641390
def cov(self, other=None, pairwise=None, ddof=1, **kwargs):
@@ -1671,7 +1697,6 @@ def count(self):
16711697
return super(Rolling, self).count()
16721698

16731699
@Substitution(name='rolling')
1674-
@Appender(_doc_template)
16751700
@Appender(_shared_docs['apply'])
16761701
def apply(self, func, raw=None, args=(), kwargs={}):
16771702
return super(Rolling, self).apply(
@@ -1945,7 +1970,6 @@ def count(self, **kwargs):
19451970
return super(Expanding, self).count(**kwargs)
19461971

19471972
@Substitution(name='expanding')
1948-
@Appender(_doc_template)
19491973
@Appender(_shared_docs['apply'])
19501974
def apply(self, func, raw=None, args=(), kwargs={}):
19511975
return super(Expanding, self).apply(
@@ -2066,7 +2090,9 @@ def _constructor(self):
20662090
Parameters
20672091
----------
20682092
bias : bool, default False
2069-
Use a standard estimation bias correction
2093+
Use a standard estimation bias correction.
2094+
*args, **kwargs
2095+
Arguments and keyword arguments to be passed into func.
20702096
"""
20712097

20722098
_pairwise_template = """
@@ -2083,7 +2109,9 @@ def _constructor(self):
20832109
inputs. In the case of missing elements, only complete pairwise
20842110
observations will be used.
20852111
bias : bool, default False
2086-
Use a standard estimation bias correction
2112+
Use a standard estimation bias correction.
2113+
**kwargs
2114+
Keyword arguments to be passed into func.
20872115
"""
20882116

20892117

@@ -2287,6 +2315,11 @@ def func(arg):
22872315
def mean(self, *args, **kwargs):
22882316
"""
22892317
Exponential weighted moving average.
2318+
2319+
Parameters
2320+
----------
2321+
*args, **kwargs
2322+
Arguments and keyword arguments to be passed into func.
22902323
"""
22912324
nv.validate_window_func('mean', args, kwargs)
22922325
return self._apply('ewma', **kwargs)

0 commit comments

Comments
 (0)