From 81f5d97728ff4ade3d206bf5315e0d189f460f5a Mon Sep 17 00:00:00 2001 From: Alejandro Hohmann Date: Sat, 10 Mar 2018 15:57:53 -0800 Subject: [PATCH 1/2] DOC: Improve the doctring of window.Rolling.min() --- 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..daa13e133dceb 100644 --- a/pandas/core/window.py +++ b/pandas/core/window.py @@ -838,9 +838,48 @@ def max(self, *args, **kwargs): return self._apply('roll_max', 'max', **kwargs) _shared_docs['min'] = dedent(""" - %(name)s minimum - """) + Calculate the %(name)s minimum. + + Parameters + ---------- + **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 a Series + DataFrame.%(name)s : Calling object with a DataFrame + Series.min : Similar method for Series + DataFrame.min : Similar method for DataFrame + + Examples + -------- + The below example will show a rolling calculation + with a window size of 3. + + >>> s = pd.Series([4,3,5,2,6]) + >>> s + 0 4 + 1 3 + 2 5 + 3 2 + 4 6 + dtype: int64 + >>> s.rolling(3).min() + 0 NaN + 1 NaN + 2 3.0 + 3 2.0 + 4 2.0 + dtype: float64 + """) + def min(self, *args, **kwargs): nv.validate_window_func('min', args, kwargs) return self._apply('roll_min', 'min', **kwargs) @@ -1230,7 +1269,6 @@ def max(self, *args, **kwargs): return super(Rolling, self).max(*args, **kwargs) @Substitution(name='rolling') - @Appender(_doc_template) @Appender(_shared_docs['min']) def min(self, *args, **kwargs): nv.validate_rolling_func('min', args, kwargs) @@ -1469,7 +1507,6 @@ def max(self, *args, **kwargs): return super(Expanding, self).max(*args, **kwargs) @Substitution(name='expanding') - @Appender(_doc_template) @Appender(_shared_docs['min']) def min(self, *args, **kwargs): nv.validate_expanding_func('min', args, kwargs) From 1a5c3cc7b11cb3f81dd42f949e2c10e2d2e207c3 Mon Sep 17 00:00:00 2001 From: Joris Van den Bossche Date: Sat, 17 Mar 2018 12:48:43 +0100 Subject: [PATCH 2/2] pep8 --- pandas/core/window.py | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/pandas/core/window.py b/pandas/core/window.py index ff6334edad941..84bbfb3c8ba4a 100644 --- a/pandas/core/window.py +++ b/pandas/core/window.py @@ -910,7 +910,7 @@ def max(self, *args, **kwargs): return self._apply('roll_max', 'max', **kwargs) _shared_docs['min'] = dedent(""" - Calculate the %(name)s minimum. + Calculate the %(name)s minimum. Parameters ---------- @@ -922,7 +922,7 @@ def max(self, *args, **kwargs): Series or DataFrame Returned object type is determined by the caller of the %(name)s calculation. - + See Also -------- Series.%(name)s : Calling object with a Series @@ -932,17 +932,9 @@ def max(self, *args, **kwargs): Examples -------- - The below example will show a rolling calculation - with a window size of 3. + Performing a rolling minimum with a window size of 3. - >>> s = pd.Series([4,3,5,2,6]) - >>> s - 0 4 - 1 3 - 2 5 - 3 2 - 4 6 - dtype: int64 + >>> s = pd.Series([4, 3, 5, 2, 6]) >>> s.rolling(3).min() 0 NaN 1 NaN @@ -951,7 +943,7 @@ def max(self, *args, **kwargs): 4 2.0 dtype: float64 """) - + def min(self, *args, **kwargs): nv.validate_window_func('min', args, kwargs) return self._apply('roll_min', 'min', **kwargs)