From 11f502705f2bf7724d645d662cbef27ee46094dc Mon Sep 17 00:00:00 2001 From: LJArendse Date: Sun, 9 Dec 2018 21:23:58 +0200 Subject: [PATCH 01/19] DOC: Fix docstring formatting for pandas.core.window.Expanding.apply and pandas.core.window.Rolling.apply The following 'errors' were fixed: - Summary does not start with a capital letter - Unknown parameters {\*args and \*\*kwargs are passed to the function} - Parameter "func" description should finish with "." - Parameter "raw" description should start with a capital letter - Parameter "\*args and \*\*kwargs are passed to the function" has no type - Parameter "\*args and \*\*kwargs are passed to the function" description should finish with "." - No Returns section found The following 'warning' was addressed: - See Also section not found --- pandas/core/window.py | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/pandas/core/window.py b/pandas/core/window.py index 8c4803a732dd8..8896b802c81ec 100644 --- a/pandas/core/window.py +++ b/pandas/core/window.py @@ -30,14 +30,15 @@ _shared_docs = dict(**_shared_docs) _doc_template = """ - Returns - ------- - same type as input - See Also - -------- - Series.%(name)s - DataFrame.%(name)s +Returns +------- +same type as input + +See Also +-------- +Series.%(name)s : Series %(name)s. +DataFrame.%(name)s : DataFrame %(name)s. """ @@ -944,17 +945,17 @@ def count(self): return self._wrap_results(results, blocks, obj) _shared_docs['apply'] = dedent(r""" - %(name)s function apply. + The %(name)s function apply. Parameters ---------- func : function Must produce a single value from an ndarray input if ``raw=True`` - or a Series if ``raw=False`` + or a Series if ``raw=False``. raw : bool, default None - * ``False`` : passes each row or column as a Series to the + If * ``False`` : passes each row or column as a Series to the function. - * ``True`` or ``None`` : the passed function will receive ndarray + If * ``True`` or ``None`` : the passed function will receive ndarray objects instead. If you are just applying a NumPy reduction function this will achieve much better performance. @@ -963,8 +964,8 @@ def count(self): not passed. In the future `raw` will default to False. .. versionadded:: 0.23.0 - - \*args and \*\*kwargs are passed to the function""") + *args, **kwargs : + Passed to the function for compatibility with other %(name)s methods.""") def apply(self, func, raw=None, args=(), kwargs={}): from pandas import Series From 9c26181912d67454ff04dcc3647ecf8990ddce60 Mon Sep 17 00:00:00 2001 From: LJArendse Date: Sun, 9 Dec 2018 21:50:37 +0200 Subject: [PATCH 02/19] DOC: Remove trailing trailing whitespace --- pandas/core/window.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/core/window.py b/pandas/core/window.py index 8896b802c81ec..bd76f6b99c453 100644 --- a/pandas/core/window.py +++ b/pandas/core/window.py @@ -37,8 +37,8 @@ See Also -------- -Series.%(name)s : Series %(name)s. -DataFrame.%(name)s : DataFrame %(name)s. +Series.%(name)s : Series %(name)s. +DataFrame.%(name)s : DataFrame %(name)s. """ From 939dfeb4eace1095cc486bb5c9b38cdef701616f Mon Sep 17 00:00:00 2001 From: LJArendse Date: Sun, 9 Dec 2018 21:54:02 +0200 Subject: [PATCH 03/19] DOC: Fix Line 968:80: E501 line too long (81 > 79 characters) --- pandas/core/window.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pandas/core/window.py b/pandas/core/window.py index bd76f6b99c453..a954f1c16b970 100644 --- a/pandas/core/window.py +++ b/pandas/core/window.py @@ -965,7 +965,8 @@ def count(self): .. versionadded:: 0.23.0 *args, **kwargs : - Passed to the function for compatibility with other %(name)s methods.""") + Passed to the function for compatibility with other %(name)s + methods.""") def apply(self, func, raw=None, args=(), kwargs={}): from pandas import Series From 4f1e16e9d76e05ec9d945481faf64add3ab28c0c Mon Sep 17 00:00:00 2001 From: LJArendse Date: Sun, 9 Dec 2018 22:01:27 +0200 Subject: [PATCH 04/19] DOC: Remove * in raw parameter description --- pandas/core/window.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/core/window.py b/pandas/core/window.py index a954f1c16b970..fc241c4ed9b72 100644 --- a/pandas/core/window.py +++ b/pandas/core/window.py @@ -953,9 +953,9 @@ def count(self): Must produce a single value from an ndarray input if ``raw=True`` or a Series if ``raw=False``. raw : bool, default None - If * ``False`` : passes each row or column as a Series to the + If ``False`` : passes each row or column as a Series to the function. - If * ``True`` or ``None`` : the passed function will receive ndarray + If ``True`` or ``None`` : the passed function will receive ndarray objects instead. If you are just applying a NumPy reduction function this will achieve much better performance. From 764f8a85a5320dd50a1eb058a175f9aed3d516fa Mon Sep 17 00:00:00 2001 From: LJArendse Date: Sun, 9 Dec 2018 22:11:58 +0200 Subject: [PATCH 05/19] DOC: Restore lines to original form --- pandas/core/window.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/core/window.py b/pandas/core/window.py index fc241c4ed9b72..7fde709715900 100644 --- a/pandas/core/window.py +++ b/pandas/core/window.py @@ -953,9 +953,9 @@ def count(self): Must produce a single value from an ndarray input if ``raw=True`` or a Series if ``raw=False``. raw : bool, default None - If ``False`` : passes each row or column as a Series to the + * ``False`` : passes each row or column as a Series to the function. - If ``True`` or ``None`` : the passed function will receive ndarray + * ``True`` or ``None`` : the passed function will receive ndarray objects instead. If you are just applying a NumPy reduction function this will achieve much better performance. From 765add7ad84c8c1e508a5954448e756087b8ab06 Mon Sep 17 00:00:00 2001 From: LJArendse Date: Sun, 9 Dec 2018 22:18:49 +0200 Subject: [PATCH 06/19] DOC: Remove tabs --- pandas/core/window.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/window.py b/pandas/core/window.py index 7fde709715900..274333feb9c1b 100644 --- a/pandas/core/window.py +++ b/pandas/core/window.py @@ -966,7 +966,7 @@ def count(self): .. versionadded:: 0.23.0 *args, **kwargs : Passed to the function for compatibility with other %(name)s - methods.""") + methods.""") def apply(self, func, raw=None, args=(), kwargs={}): from pandas import Series From ad0cd6a8a016637f100f5df4610028ce9793ff7f Mon Sep 17 00:00:00 2001 From: LJArendse Date: Sun, 9 Dec 2018 22:42:29 +0200 Subject: [PATCH 07/19] DOC: Amend the description of *args, **kwargs --- pandas/core/window.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pandas/core/window.py b/pandas/core/window.py index 274333feb9c1b..b6121578f9ca2 100644 --- a/pandas/core/window.py +++ b/pandas/core/window.py @@ -965,8 +965,7 @@ def count(self): .. versionadded:: 0.23.0 *args, **kwargs : - Passed to the function for compatibility with other %(name)s - methods.""") + Arguments and keyword arguments to be passed into func.""") def apply(self, func, raw=None, args=(), kwargs={}): from pandas import Series From dead755db0495d31ca7b75e44b9d16633df8ae2d Mon Sep 17 00:00:00 2001 From: LJArendse Date: Mon, 10 Dec 2018 18:36:30 +0200 Subject: [PATCH 08/19] DOC: Return _doc_template to original form, Update _shared_docs['apply'] docstring, and Remove @Appender(_doc_template) decorator for rolling apply and expanding apply --- pandas/core/window.py | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/pandas/core/window.py b/pandas/core/window.py index b6121578f9ca2..b5f2c63db245b 100644 --- a/pandas/core/window.py +++ b/pandas/core/window.py @@ -30,15 +30,14 @@ _shared_docs = dict(**_shared_docs) _doc_template = """ + Returns + ------- + same type as input -Returns -------- -same type as input - -See Also --------- -Series.%(name)s : Series %(name)s. -DataFrame.%(name)s : DataFrame %(name)s. + See Also + -------- + Series.%(name)s + DataFrame.%(name)s """ @@ -965,7 +964,17 @@ def count(self): .. versionadded:: 0.23.0 *args, **kwargs : - Arguments and keyword arguments to be passed into func.""") + Arguments and keyword arguments to be passed into func. + + Returns + ------- + Same type as input + + See Also + -------- + Series.%(name)s : Series %(name)s. + DataFrame.%(name)s : DataFrame %(name)s. + """) def apply(self, func, raw=None, args=(), kwargs={}): from pandas import Series @@ -1667,7 +1676,6 @@ def count(self): return super(Rolling, self).count() @Substitution(name='rolling') - @Appender(_doc_template) @Appender(_shared_docs['apply']) def apply(self, func, raw=None, args=(), kwargs={}): return super(Rolling, self).apply( @@ -1938,7 +1946,6 @@ def count(self, **kwargs): return super(Expanding, self).count(**kwargs) @Substitution(name='expanding') - @Appender(_doc_template) @Appender(_shared_docs['apply']) def apply(self, func, raw=None, args=(), kwargs={}): return super(Expanding, self).apply( From f20e9515414be38458efc147c4e0e6f420069696 Mon Sep 17 00:00:00 2001 From: LJArendse Date: Tue, 11 Dec 2018 18:44:18 +0200 Subject: [PATCH 09/19] DOC: Modify apply method's return section in docstring --- pandas/core/window.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pandas/core/window.py b/pandas/core/window.py index b5f2c63db245b..9bc444baeedc2 100644 --- a/pandas/core/window.py +++ b/pandas/core/window.py @@ -968,7 +968,9 @@ def count(self): Returns ------- - Same type as input + Series or DataFrame + Returned object type is determined by the caller of the + %(name)s apply. See Also -------- From 95c3cad98d22682a85684484342b90939eaebfa5 Mon Sep 17 00:00:00 2001 From: LJArendse Date: Tue, 11 Dec 2018 20:19:49 +0200 Subject: [PATCH 10/19] DOC: Simplify explination of the return type in apply docstring --- pandas/core/window.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pandas/core/window.py b/pandas/core/window.py index 9bc444baeedc2..27c2001a4afc0 100644 --- a/pandas/core/window.py +++ b/pandas/core/window.py @@ -969,8 +969,7 @@ def count(self): Returns ------- Series or DataFrame - Returned object type is determined by the caller of the - %(name)s apply. + Return type is determined by the caller. See Also -------- From 95cd423c24a6886c19497098ab39da2266cd6968 Mon Sep 17 00:00:00 2001 From: LJArendse Date: Wed, 12 Dec 2018 21:35:23 +0200 Subject: [PATCH 11/19] DOC: Modify and improve on the current _doc_template --- pandas/core/window.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pandas/core/window.py b/pandas/core/window.py index 27c2001a4afc0..4cf50d8927990 100644 --- a/pandas/core/window.py +++ b/pandas/core/window.py @@ -32,12 +32,13 @@ _doc_template = """ Returns ------- - same type as input + Series or DataFrame + Return type is determined by the caller. See Also -------- - Series.%(name)s - DataFrame.%(name)s + Series.%(name)s : Series %(name)s. + DataFrame.%(name)s : DataFrame %(name)s. """ From a6447b50aeffe119deef72fc6a4cfa1260776fdc Mon Sep 17 00:00:00 2001 From: LJArendse Date: Sat, 15 Dec 2018 11:49:43 +0200 Subject: [PATCH 12/19] DOC: Update _shared_docs['apply'] function description --- pandas/core/window.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/window.py b/pandas/core/window.py index 4cf50d8927990..3a5a04d2322b2 100644 --- a/pandas/core/window.py +++ b/pandas/core/window.py @@ -945,7 +945,7 @@ def count(self): return self._wrap_results(results, blocks, obj) _shared_docs['apply'] = dedent(r""" - The %(name)s function apply. + The %(name)s function's apply function. Parameters ---------- From b6cad28c855b16dc57e07bd48d0aa5aeb9df37b8 Mon Sep 17 00:00:00 2001 From: LJArendse Date: Sun, 6 Jan 2019 21:28:10 +0200 Subject: [PATCH 13/19] DOC: Add **kwarg parameter to _shared_docs['skew'] --- pandas/core/window.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pandas/core/window.py b/pandas/core/window.py index 8ef9d8788711c..4224b5b57814b 100644 --- a/pandas/core/window.py +++ b/pandas/core/window.py @@ -1239,7 +1239,14 @@ def var(self, ddof=1, *args, **kwargs): check_minp=_require_min_periods(1), ddof=ddof, **kwargs) - _shared_docs['skew'] = """Unbiased %(name)s skewness""" + _shared_docs['skew'] = """ + Unbiased %(name)s skewness. + + Parameters + ---------- + **kwargs : + Keyword arguments to be passed into func. + """ def skew(self, **kwargs): return self._apply('roll_skew', 'skew', From 958f16fffc4d3fb7a98b037b418f91e4a42f35f3 Mon Sep 17 00:00:00 2001 From: LJArendse Date: Mon, 7 Jan 2019 11:29:40 +0200 Subject: [PATCH 14/19] DOC: Add *args, **kwargs parameters to _shared_docs['max'] docstring --- pandas/core/window.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pandas/core/window.py b/pandas/core/window.py index 4224b5b57814b..259a87f5d0af8 100644 --- a/pandas/core/window.py +++ b/pandas/core/window.py @@ -1017,6 +1017,11 @@ def sum(self, *args, **kwargs): _shared_docs['max'] = dedent(""" Calculate the %(name)s maximum. + + Parameters + ---------- + *args, **kwargs : + Arguments and keyword arguments to be passed into func. """) def max(self, *args, **kwargs): From 61d3a9241b82767a7f02a2388d830e61540bcf9c Mon Sep 17 00:00:00 2001 From: LJArendse Date: Mon, 7 Jan 2019 11:39:29 +0200 Subject: [PATCH 15/19] Add **kwargs parameter to docstrings of Rolling.cov, Expanding.cov, and EWM.cov --- pandas/core/window.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pandas/core/window.py b/pandas/core/window.py index 259a87f5d0af8..8f17e258ce9de 100644 --- a/pandas/core/window.py +++ b/pandas/core/window.py @@ -1383,6 +1383,8 @@ def f(arg, *args, **kwargs): ddof : int, default 1 Delta Degrees of Freedom. The divisor used in calculations is ``N - ddof``, where ``N`` represents the number of elements. + **kwargs : + Keyword arguments to be passed into func. """ def cov(self, other=None, pairwise=None, ddof=1, **kwargs): @@ -2105,7 +2107,9 @@ def _constructor(self): inputs. In the case of missing elements, only complete pairwise observations will be used. bias : bool, default False - Use a standard estimation bias correction + Use a standard estimation bias correction. + **kwargs : + Keyword arguments to be passed into func. """ From d0a5f03e84d6030a01e10a6d19bea58b9a42c74a Mon Sep 17 00:00:00 2001 From: LJArendse Date: Mon, 7 Jan 2019 11:44:54 +0200 Subject: [PATCH 16/19] DOC: Add *args, **kwargs parameters to EWM.mean docstring --- pandas/core/window.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pandas/core/window.py b/pandas/core/window.py index 8f17e258ce9de..d366b4bc28988 100644 --- a/pandas/core/window.py +++ b/pandas/core/window.py @@ -2313,6 +2313,11 @@ def func(arg): def mean(self, *args, **kwargs): """ Exponential weighted moving average. + + Parameters + ---------- + *args, **kwargs : + Arguments and keyword arguments to be passed into func. """ nv.validate_window_func('mean', args, kwargs) return self._apply('ewma', **kwargs) From 7c19bae6e6c57e0bd680d18bc75cbf6b6b11f1b5 Mon Sep 17 00:00:00 2001 From: LJArendse Date: Mon, 7 Jan 2019 11:48:17 +0200 Subject: [PATCH 17/19] DOC: Add *args, **kwargs parameters to EWM.std docstring --- pandas/core/window.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pandas/core/window.py b/pandas/core/window.py index d366b4bc28988..c21b539cc2c39 100644 --- a/pandas/core/window.py +++ b/pandas/core/window.py @@ -2091,6 +2091,8 @@ def _constructor(self): ---------- bias : bool, default False Use a standard estimation bias correction + *args, **kwargs : + Arguments and keyword arguments to be passed into func. """ _pairwise_template = """ From 7cc3626e5cac339aabcfcc07a5dd4fed17a58d0e Mon Sep 17 00:00:00 2001 From: LJArendse Date: Mon, 7 Jan 2019 11:50:22 +0200 Subject: [PATCH 18/19] DOC: Add . to the end of the bias' parameter description --- pandas/core/window.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/window.py b/pandas/core/window.py index c21b539cc2c39..9d2d6bea0aa76 100644 --- a/pandas/core/window.py +++ b/pandas/core/window.py @@ -2090,7 +2090,7 @@ def _constructor(self): Parameters ---------- bias : bool, default False - Use a standard estimation bias correction + Use a standard estimation bias correction. *args, **kwargs : Arguments and keyword arguments to be passed into func. """ From 8bedb9d591a9b1bf6b6264f1595ad38953b7aa33 Mon Sep 17 00:00:00 2001 From: LJArendse Date: Mon, 7 Jan 2019 13:30:19 +0200 Subject: [PATCH 19/19] DOC: Remove : at the of the *args, **kwargs parameters --- pandas/core/window.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pandas/core/window.py b/pandas/core/window.py index 9d2d6bea0aa76..5a9157b43ecd6 100644 --- a/pandas/core/window.py +++ b/pandas/core/window.py @@ -966,7 +966,7 @@ def count(self): not passed. In the future `raw` will default to False. .. versionadded:: 0.23.0 - *args, **kwargs : + *args, **kwargs Arguments and keyword arguments to be passed into func. Returns @@ -1020,7 +1020,7 @@ def sum(self, *args, **kwargs): Parameters ---------- - *args, **kwargs : + *args, **kwargs Arguments and keyword arguments to be passed into func. """) @@ -1249,7 +1249,7 @@ def var(self, ddof=1, *args, **kwargs): Parameters ---------- - **kwargs : + **kwargs Keyword arguments to be passed into func. """ @@ -1383,7 +1383,7 @@ def f(arg, *args, **kwargs): ddof : int, default 1 Delta Degrees of Freedom. The divisor used in calculations is ``N - ddof``, where ``N`` represents the number of elements. - **kwargs : + **kwargs Keyword arguments to be passed into func. """ @@ -2091,7 +2091,7 @@ def _constructor(self): ---------- bias : bool, default False Use a standard estimation bias correction. - *args, **kwargs : + *args, **kwargs Arguments and keyword arguments to be passed into func. """ @@ -2110,7 +2110,7 @@ def _constructor(self): observations will be used. bias : bool, default False Use a standard estimation bias correction. - **kwargs : + **kwargs Keyword arguments to be passed into func. """ @@ -2318,7 +2318,7 @@ def mean(self, *args, **kwargs): Parameters ---------- - *args, **kwargs : + *args, **kwargs Arguments and keyword arguments to be passed into func. """ nv.validate_window_func('mean', args, kwargs)