From 6f59df9c8b6a530fef62c59779d1064d3af3f68d Mon Sep 17 00:00:00 2001 From: Tommy Stone Date: Sat, 10 Mar 2018 15:50:32 -0800 Subject: [PATCH 1/6] updated windows.py count docstring --- pandas/core/window.py | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/pandas/core/window.py b/pandas/core/window.py index c41b07759d555..68f23291c6d8f 100644 --- a/pandas/core/window.py +++ b/pandas/core/window.py @@ -780,9 +780,41 @@ def calc(x): class _Rolling_and_Expanding(_Rolling): - _shared_docs['count'] = """%(name)s count of number of non-NaN - observations inside provided window.""" + _shared_docs['count'] = dedent(r""" + The %(name)s sum if it is a non-Nan value inside the window. + + Returns + ------- + Returns the object type with the sum of the window values in the current row. + + See Also + -------- + Series.%(name)s : Calling object with Series data + DataFrame.%(name)s : Calling object with DataFrames + + Examples + -------- + >>> s = pd.Series([2, 3, np.nan, 'values']) + >>> s.rolling(2).count() + 0 1.0 + 1 2.0 + 2 1.0 + 3 1.0 + dtype: float64 + >>> s.rolling(3).count() + 0 1.0 + 1 2.0 + 2 2.0 + 3 2.0 + dtype: float64 + >>> s.rolling(4).count() + 0 1.0 + 1 2.0 + 2 2.0 + 3 3.0 + dtype: float64 + """) def count(self): blocks, obj, index = self._create_blocks() @@ -1199,7 +1231,6 @@ def aggregate(self, arg, *args, **kwargs): agg = aggregate @Substitution(name='rolling') - @Appender(_doc_template) @Appender(_shared_docs['count']) def count(self): From 4c1500c67d9c19d87464aaf6d9bc685ade17aec7 Mon Sep 17 00:00:00 2001 From: Tommy Stone Date: Sat, 10 Mar 2018 16:02:37 -0800 Subject: [PATCH 2/6] DOC: update the pandas.core.window.Rolling.count docstring --- pandas/core/window.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pandas/core/window.py b/pandas/core/window.py index 68f23291c6d8f..ca177734964d7 100644 --- a/pandas/core/window.py +++ b/pandas/core/window.py @@ -780,21 +780,21 @@ def calc(x): class _Rolling_and_Expanding(_Rolling): - _shared_docs['count'] = dedent(r""" The %(name)s sum if it is a non-Nan value inside the window. Returns ------- - Returns the object type with the sum of the window values in the current row. + Returns the object type with the sum of the window values + in the current row. See Also -------- Series.%(name)s : Calling object with Series data - DataFrame.%(name)s : Calling object with DataFrames + DataFrame.%(name)s : Calling object with DataFrames Examples - -------- + -------- >>> s = pd.Series([2, 3, np.nan, 'values']) >>> s.rolling(2).count() 0 1.0 @@ -815,6 +815,7 @@ class _Rolling_and_Expanding(_Rolling): 3 3.0 dtype: float64 """) + def count(self): blocks, obj, index = self._create_blocks() From a59c9cba9c30af762eb917b3e76acb456773046f Mon Sep 17 00:00:00 2001 From: Tommy Stone Date: Sat, 17 Mar 2018 14:44:19 -0700 Subject: [PATCH 3/6] Received comments on updating description to use count, return type and examples. Updated information --- pandas/core/window.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pandas/core/window.py b/pandas/core/window.py index ca177734964d7..0cef4ddff17b4 100644 --- a/pandas/core/window.py +++ b/pandas/core/window.py @@ -781,21 +781,21 @@ def calc(x): class _Rolling_and_Expanding(_Rolling): _shared_docs['count'] = dedent(r""" - The %(name)s sum if it is a non-Nan value inside the window. + The %(name)'s count of any non-Nan values inside the window. Returns ------- - Returns the object type with the sum of the window values - in the current row. + Series or Dataframe + Returned object type is determined by the caller of %(name) See Also -------- - Series.%(name)s : Calling object with Series data - DataFrame.%(name)s : Calling object with DataFrames + pandas.Series.%(name)s + pandas.DataFrame.%(name)s Examples -------- - >>> s = pd.Series([2, 3, np.nan, 'values']) + >>> s = pd.Series([2, 3, np.nan, 10]) >>> s.rolling(2).count() 0 1.0 1 2.0 From 122f930a494a5ded40795cb999d49e612106228a Mon Sep 17 00:00:00 2001 From: Tommy Stone Date: Sat, 17 Mar 2018 15:03:17 -0700 Subject: [PATCH 4/6] updated See Also section to remove typo with calling objects --- 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 0cef4ddff17b4..0b701b5fdfa69 100644 --- a/pandas/core/window.py +++ b/pandas/core/window.py @@ -790,8 +790,8 @@ class _Rolling_and_Expanding(_Rolling): See Also -------- - pandas.Series.%(name)s - pandas.DataFrame.%(name)s + pandas.Series.%(name) + pandas.DataFrame.%(name) Examples -------- From f8d77ef33416cfe9d076317881a7c70f30949ebc Mon Sep 17 00:00:00 2001 From: Tommy Stone Date: Sun, 18 Mar 2018 00:28:44 -0700 Subject: [PATCH 5/6] updated count docstring based on comments --- pandas/core/window.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pandas/core/window.py b/pandas/core/window.py index 0b701b5fdfa69..cd056521e2cfa 100644 --- a/pandas/core/window.py +++ b/pandas/core/window.py @@ -781,17 +781,17 @@ def calc(x): class _Rolling_and_Expanding(_Rolling): _shared_docs['count'] = dedent(r""" - The %(name)'s count of any non-Nan values inside the window. + The %(name)s count of any non-Nan observations inside the window. Returns ------- - Series or Dataframe - Returned object type is determined by the caller of %(name) + Returned object type is determined by the caller of the %(name)s + calculation. See Also -------- - pandas.Series.%(name) - pandas.DataFrame.%(name) + pandas.Series.%(name)s : Calling object with Series data + pandas.DataFrame.%(name)s : Calling object with DataFrames Examples -------- From 946836c13c52da33598ace32aeff26bc3bc3f070 Mon Sep 17 00:00:00 2001 From: Joris Van den Bossche Date: Mon, 19 Mar 2018 22:11:30 +0100 Subject: [PATCH 6/6] also remove doc_template for expanding --- pandas/core/window.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pandas/core/window.py b/pandas/core/window.py index cd056521e2cfa..14a0b851d0470 100644 --- a/pandas/core/window.py +++ b/pandas/core/window.py @@ -781,17 +781,19 @@ def calc(x): class _Rolling_and_Expanding(_Rolling): _shared_docs['count'] = dedent(r""" - The %(name)s count of any non-Nan observations inside the window. + The %(name)s count of any non-NaN observations inside the window. Returns ------- - Returned object type is determined by the caller of the %(name)s - calculation. + Series or DataFrame + Returned object type is determined by the caller of the %(name)s + calculation. See Also -------- pandas.Series.%(name)s : Calling object with Series data pandas.DataFrame.%(name)s : Calling object with DataFrames + pandas.DataFrame.count : Count of the full DataFrame Examples -------- @@ -1475,7 +1477,6 @@ def aggregate(self, arg, *args, **kwargs): agg = aggregate @Substitution(name='expanding') - @Appender(_doc_template) @Appender(_shared_docs['count']) def count(self, **kwargs): return super(Expanding, self).count(**kwargs)