From 1400b71d396151ff191014027ab770744723516a Mon Sep 17 00:00:00 2001 From: Johnny Metz Date: Sat, 10 Mar 2018 15:21:05 -0800 Subject: [PATCH 1/3] DOC: Improve the docstring of window mean functions. --- pandas/core/window.py | 45 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/pandas/core/window.py b/pandas/core/window.py index c41b07759d555..f07cbfeeef423 100644 --- a/pandas/core/window.py +++ b/pandas/core/window.py @@ -323,7 +323,47 @@ def aggregate(self, arg, *args, **kwargs): %(name)s sum""") _shared_docs['mean'] = dedent(""" - %(name)s mean""") + Calculate the %(name)s mean of the values. + + Parameters + ---------- + *args + Under Review. + **kwargs + Under Review. + + Returns + ------- + Series or DataFrame + Returned object type is determined by the caller of the %(name)s + calculation. + + See Also + -------- + Series.%(name)s : Calling object with Series data + DataFrame.%(name)s : Calling object with DataFrames + Series.mean : Equivalent method for Series + DataFrame.mean : Equivalent method for DataFrame + + Examples + -------- + The below example will show rolling mean calculations with window sizes of + two and three, respectively. + + >>> s = pd.Series([1, 2, 3, 4]) + >>> s.rolling(2).mean() + 0 NaN + 1 1.5 + 2 2.5 + 3 3.5 + dtype: float64 + >>> s.rolling(3).mean() + 0 NaN + 1 NaN + 2 2.0 + 3 3.0 + dtype: float64 + """) class Window(_Window): @@ -646,7 +686,6 @@ def sum(self, *args, **kwargs): return self._apply_window(mean=False, **kwargs) @Substitution(name='window') - @Appender(_doc_template) @Appender(_shared_docs['mean']) def mean(self, *args, **kwargs): nv.validate_window_func('mean', args, kwargs) @@ -1237,7 +1276,6 @@ def min(self, *args, **kwargs): return super(Rolling, self).min(*args, **kwargs) @Substitution(name='rolling') - @Appender(_doc_template) @Appender(_shared_docs['mean']) def mean(self, *args, **kwargs): nv.validate_rolling_func('mean', args, kwargs) @@ -1476,7 +1514,6 @@ def min(self, *args, **kwargs): return super(Expanding, self).min(*args, **kwargs) @Substitution(name='expanding') - @Appender(_doc_template) @Appender(_shared_docs['mean']) def mean(self, *args, **kwargs): nv.validate_expanding_func('mean', args, kwargs) From a9a510c0ca232ee5ea6abae49c31679e210c5928 Mon Sep 17 00:00:00 2001 From: Johnny Metz Date: Mon, 12 Mar 2018 00:23:37 -0700 Subject: [PATCH 2/3] DOC: Add line between examples for pandas.core.window.x.mean. --- 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 f07cbfeeef423..32e85ed40a459 100644 --- a/pandas/core/window.py +++ b/pandas/core/window.py @@ -347,7 +347,7 @@ def aggregate(self, arg, *args, **kwargs): Examples -------- - The below example will show rolling mean calculations with window sizes of + The below examples will show rolling mean calculations with window sizes of two and three, respectively. >>> s = pd.Series([1, 2, 3, 4]) @@ -357,6 +357,7 @@ def aggregate(self, arg, *args, **kwargs): 2 2.5 3 3.5 dtype: float64 + >>> s.rolling(3).mean() 0 NaN 1 NaN From a09533cbeb1da406b2364b444cc56eaa3363de95 Mon Sep 17 00:00:00 2001 From: Johnny Metz Date: Mon, 12 Mar 2018 00:27:54 -0700 Subject: [PATCH 3/3] DOC: Remove whitespace in blank line for pandas.core.window.x.mean. --- 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 32e85ed40a459..9e7ed5721cab5 100644 --- a/pandas/core/window.py +++ b/pandas/core/window.py @@ -357,7 +357,7 @@ def aggregate(self, arg, *args, **kwargs): 2 2.5 3 3.5 dtype: float64 - + >>> s.rolling(3).mean() 0 NaN 1 NaN