From 4e1b71a1db9d6eb386b948b2e42db9c4de00de1f Mon Sep 17 00:00:00 2001 From: apallekonda Date: Sat, 10 Mar 2018 19:27:35 -0800 Subject: [PATCH 1/5] DOC: Update the pandas.core.window.x.sum docstring --- pandas/core/window.py | 53 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 49 insertions(+), 4 deletions(-) diff --git a/pandas/core/window.py b/pandas/core/window.py index cef012bb33e9f..b67bb74eedb04 100644 --- a/pandas/core/window.py +++ b/pandas/core/window.py @@ -320,7 +320,52 @@ def aggregate(self, arg, *args, **kwargs): agg = aggregate _shared_docs['sum'] = dedent(""" - %(name)s sum""") + Calculate %(name)s sum of given DataFrame or Series. + + Parameters + ---------- + *args + Under Review. + **kwargs + Under Review. + + Returns + ------- + Series or DataFrame + Like-indexed object containing the result of function application + + See Also + -------- + Series.%(name)s : Calling object with Series data + DataFrame.%(name)s : Calling object with DataFrame data + Series.sum : Equivalent method for Series + DataFrame.sum : Equivalent method for DataFrame + + Examples + -------- + >>> s = pd.Series([1, 2, 3, 4, 5]) + >>> s.rolling(3).sum() + 0 NaN + 1 NaN + 2 6.0 + 3 9.0 + 4 12.0 + dtype: float64 + >>> s.expanding(3).sum() + 0 NaN + 1 NaN + 2 6.0 + 3 10.0 + 4 15.0 + dtype: float64 + >>> s.rolling(3, center=True).sum() + 0 NaN + 1 6.0 + 2 9.0 + 3 12.0 + 4 NaN + dtype: float64 + """) _shared_docs['mean'] = dedent(""" %(name)s mean""") @@ -639,7 +684,7 @@ def aggregate(self, arg, *args, **kwargs): agg = aggregate @Substitution(name='window') - @Appender(_doc_template) +## @Appender(_doc_template) @Appender(_shared_docs['sum']) def sum(self, *args, **kwargs): nv.validate_window_func('sum', args, kwargs) @@ -1213,7 +1258,7 @@ def apply(self, func, args=(), kwargs={}): return super(Rolling, self).apply(func, args=args, kwargs=kwargs) @Substitution(name='rolling') - @Appender(_doc_template) +## @Appender(_doc_template) @Appender(_shared_docs['sum']) def sum(self, *args, **kwargs): nv.validate_rolling_func('sum', args, kwargs) @@ -1452,7 +1497,7 @@ def apply(self, func, args=(), kwargs={}): return super(Expanding, self).apply(func, args=args, kwargs=kwargs) @Substitution(name='expanding') - @Appender(_doc_template) +## @Appender(_doc_template) @Appender(_shared_docs['sum']) def sum(self, *args, **kwargs): nv.validate_expanding_func('sum', args, kwargs) From 20f82d28722201ebb4a4115a4b4b3e590cd6f5ba Mon Sep 17 00:00:00 2001 From: apallekonda Date: Sat, 10 Mar 2018 19:38:46 -0800 Subject: [PATCH 2/5] DOC: Update the pandas.core.window.x.sum docstring --- pandas/core/window.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pandas/core/window.py b/pandas/core/window.py index b67bb74eedb04..471a4e6d7e4d9 100644 --- a/pandas/core/window.py +++ b/pandas/core/window.py @@ -684,7 +684,7 @@ def aggregate(self, arg, *args, **kwargs): agg = aggregate @Substitution(name='window') -## @Appender(_doc_template) +# @Appender(_doc_template) @Appender(_shared_docs['sum']) def sum(self, *args, **kwargs): nv.validate_window_func('sum', args, kwargs) @@ -1258,7 +1258,7 @@ def apply(self, func, args=(), kwargs={}): return super(Rolling, self).apply(func, args=args, kwargs=kwargs) @Substitution(name='rolling') -## @Appender(_doc_template) +# @Appender(_doc_template) @Appender(_shared_docs['sum']) def sum(self, *args, **kwargs): nv.validate_rolling_func('sum', args, kwargs) @@ -1497,7 +1497,7 @@ def apply(self, func, args=(), kwargs={}): return super(Expanding, self).apply(func, args=args, kwargs=kwargs) @Substitution(name='expanding') -## @Appender(_doc_template) +# @Appender(_doc_template) @Appender(_shared_docs['sum']) def sum(self, *args, **kwargs): nv.validate_expanding_func('sum', args, kwargs) From f2c4ef6f78301f881f5073f7c917cf179e857e7b Mon Sep 17 00:00:00 2001 From: Anil Kumar Pallekonda Date: Sun, 11 Mar 2018 16:03:32 -0700 Subject: [PATCH 3/5] Update window.py Changes to the pandas.core.window.x.sum docstring --- pandas/core/window.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/pandas/core/window.py b/pandas/core/window.py index 471a4e6d7e4d9..2eb24ef4f8986 100644 --- a/pandas/core/window.py +++ b/pandas/core/window.py @@ -332,14 +332,14 @@ def aggregate(self, arg, *args, **kwargs): Returns ------- Series or DataFrame - Like-indexed object containing the result of function application + Like-indexed object containing the result of function application. See Also -------- Series.%(name)s : Calling object with Series data - DataFrame.%(name)s : Calling object with DataFrame data - Series.sum : Equivalent method for Series - DataFrame.sum : Equivalent method for DataFrame + DataFrame.%(name)s : Calling object with DataFrame data + Series.sum : Equivalent method for Series + DataFrame.sum : Equivalent method for DataFrame Examples -------- @@ -351,6 +351,7 @@ def aggregate(self, arg, *args, **kwargs): 3 9.0 4 12.0 dtype: float64 + >>> s.expanding(3).sum() 0 NaN 1 NaN @@ -358,6 +359,7 @@ def aggregate(self, arg, *args, **kwargs): 3 10.0 4 15.0 dtype: float64 + >>> s.rolling(3, center=True).sum() 0 NaN 1 6.0 @@ -365,6 +367,8 @@ def aggregate(self, arg, *args, **kwargs): 3 12.0 4 NaN dtype: float64 + + 'center =True' argument will place the results in center of the resultset. """) _shared_docs['mean'] = dedent(""" @@ -684,7 +688,6 @@ def aggregate(self, arg, *args, **kwargs): agg = aggregate @Substitution(name='window') -# @Appender(_doc_template) @Appender(_shared_docs['sum']) def sum(self, *args, **kwargs): nv.validate_window_func('sum', args, kwargs) @@ -1258,7 +1261,6 @@ def apply(self, func, args=(), kwargs={}): return super(Rolling, self).apply(func, args=args, kwargs=kwargs) @Substitution(name='rolling') -# @Appender(_doc_template) @Appender(_shared_docs['sum']) def sum(self, *args, **kwargs): nv.validate_rolling_func('sum', args, kwargs) @@ -1497,7 +1499,6 @@ def apply(self, func, args=(), kwargs={}): return super(Expanding, self).apply(func, args=args, kwargs=kwargs) @Substitution(name='expanding') -# @Appender(_doc_template) @Appender(_shared_docs['sum']) def sum(self, *args, **kwargs): nv.validate_expanding_func('sum', args, kwargs) From 0cfe90e918eeed56a13684a1ec9a67288f53b9f2 Mon Sep 17 00:00:00 2001 From: Tom Augspurger Date: Wed, 14 Mar 2018 14:26:58 -0500 Subject: [PATCH 4/5] Updated [ci skip] [ci skip] --- pandas/core/window.py | 49 +++++++++++++++++++++++++++++++------------ 1 file changed, 36 insertions(+), 13 deletions(-) diff --git a/pandas/core/window.py b/pandas/core/window.py index ce3b1ff5b42a4..9252810c7ad4d 100644 --- a/pandas/core/window.py +++ b/pandas/core/window.py @@ -324,26 +324,32 @@ def aggregate(self, arg, *args, **kwargs): Parameters ---------- - *args - Under Review. - **kwargs - Under Review. + *args, **kwargs + For compatibility with other %(name)s methods. Has no effect + on the computed median. Returns ------- Series or DataFrame - Like-indexed object containing the result of function application. + Same type as the input, with the same index, containing the + %(name)s sum. See Also -------- - Series.%(name)s : Calling object with Series data - DataFrame.%(name)s : Calling object with DataFrame data - Series.sum : Equivalent method for Series - DataFrame.sum : Equivalent method for DataFrame + Series.sum : Reducing sum for Series. + DataFrame.sum : Reducing sum for DataFrame. Examples -------- >>> s = pd.Series([1, 2, 3, 4, 5]) + >>> s + 0 1 + 1 2 + 2 3 + 3 4 + 4 5 + dtype: int64 + >>> s.rolling(3).sum() 0 NaN 1 NaN @@ -351,7 +357,7 @@ def aggregate(self, arg, *args, **kwargs): 3 9.0 4 12.0 dtype: float64 - + >>> s.expanding(3).sum() 0 NaN 1 NaN @@ -359,7 +365,7 @@ def aggregate(self, arg, *args, **kwargs): 3 10.0 4 15.0 dtype: float64 - + >>> s.rolling(3, center=True).sum() 0 NaN 1 6.0 @@ -367,8 +373,25 @@ def aggregate(self, arg, *args, **kwargs): 3 12.0 4 NaN dtype: float64 - - 'center =True' argument will place the results in center of the resultset. + + For DataFrame, each %(name)s sum is computed column-wise. + + >>> df = pd.DataFrame({"A": s, "B": s ** 2}) + >>> df + A B + 0 1 1 + 1 2 4 + 2 3 9 + 3 4 16 + 4 5 25 + + >>> df.rolling(3).sum() + A B + 0 NaN NaN + 1 NaN NaN + 2 6.0 14.0 + 3 9.0 29.0 + 4 12.0 50.0 """) _shared_docs['mean'] = dedent(""" From d1a2b8d4e2a6d9a0a1b724a40695de4aa0f14806 Mon Sep 17 00:00:00 2001 From: Tom Augspurger Date: Wed, 14 Mar 2018 14:29:29 -0500 Subject: [PATCH 5/5] Fixup [ci skip] [ci skip] --- 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 9252810c7ad4d..358ef98e1c072 100644 --- a/pandas/core/window.py +++ b/pandas/core/window.py @@ -326,7 +326,7 @@ def aggregate(self, arg, *args, **kwargs): ---------- *args, **kwargs For compatibility with other %(name)s methods. Has no effect - on the computed median. + on the computed value. Returns -------