From 704266c32b0373b7b12d41635304924763356a2a Mon Sep 17 00:00:00 2001 From: David Mrva Date: Sat, 24 Oct 2020 18:12:21 +0100 Subject: [PATCH 1/6] replace Appender decorator with doc --- pandas/core/generic.py | 2 +- pandas/core/shared_docs.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 36ce2c4776bd0..aebdba5ca0b40 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -8516,7 +8516,7 @@ def ranker(data): return ranker(data) - @Appender(_shared_docs["compare"] % _shared_doc_kwargs) + @doc(_shared_docs["compare"], klass=_shared_doc_kwargs["klass"]) def compare( self, other, diff --git a/pandas/core/shared_docs.py b/pandas/core/shared_docs.py index c9940c78b8d7d..cc918c27b5c2e 100644 --- a/pandas/core/shared_docs.py +++ b/pandas/core/shared_docs.py @@ -47,16 +47,16 @@ _shared_docs[ "compare" ] = """ -Compare to another %(klass)s and show the differences. +Compare to another {klass} and show the differences. .. versionadded:: 1.1.0 Parameters ---------- -other : %(klass)s +other : {klass} Object to compare with. -align_axis : {0 or 'index', 1 or 'columns'}, default 1 +align_axis : {{0 or 'index', 1 or 'columns'}}, default 1 Determine which axis to align the comparison on. * 0, or 'index' : Resulting differences are stacked vertically From 6e31a83f51d1b5d9e507c79ba18558b64b44efb4 Mon Sep 17 00:00:00 2001 From: David Mrva Date: Mon, 2 Nov 2020 21:05:39 +0000 Subject: [PATCH 2/6] replaced Appender with doc for Frame.compare() and Series.compare() --- pandas/core/frame.py | 6 ++---- pandas/core/series.py | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 049d2c4888a69..6745653638c17 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -6032,7 +6032,7 @@ def __rdivmod__(self, other) -> Tuple[DataFrame, DataFrame]: # ---------------------------------------------------------------------- # Combination-Related - @Appender( + @doc(_shared_docs["compare"], """ Returns ------- @@ -6134,9 +6134,7 @@ def __rdivmod__(self, other) -> Tuple[DataFrame, DataFrame]: 2 b b 3.0 3.0 3.0 4.0 3 b b NaN NaN 4.0 4.0 4 a a 5.0 5.0 5.0 5.0 -""" - ) - @Appender(_shared_docs["compare"] % _shared_doc_kwargs) +""", klass=_shared_doc_kwargs["klass"]) def compare( self, other: DataFrame, diff --git a/pandas/core/series.py b/pandas/core/series.py index e4a805a18bcdb..2e65aca0770c1 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -2813,7 +2813,7 @@ def _construct_result( out.name = name return out - @Appender( + @doc(generic._shared_docs["compare"], """ Returns ------- @@ -2873,9 +2873,7 @@ def _construct_result( 2 c c 3 d b 4 e e -""" - ) - @Appender(generic._shared_docs["compare"] % _shared_doc_kwargs) +""", klass=_shared_doc_kwargs["klass"]) def compare( self, other: "Series", From 417231d0ea8190d9e36b192543e94353c69a34ba Mon Sep 17 00:00:00 2001 From: David Mrva Date: Fri, 6 Nov 2020 18:04:24 +0000 Subject: [PATCH 3/6] fix a doc string format --- pandas/core/frame.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 6745653638c17..6d694c3e80a61 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -6062,11 +6062,11 @@ def __rdivmod__(self, other) -> Tuple[DataFrame, DataFrame]: Examples -------- >>> df = pd.DataFrame( -... { +... {{ ... "col1": ["a", "a", "b", "b", "a"], ... "col2": [1.0, 2.0, 3.0, np.nan, 5.0], ... "col3": [1.0, 2.0, 3.0, 4.0, 5.0] -... }, +... }}, ... columns=["col1", "col2", "col3"], ... ) >>> df From 464f4b1cc11d719f038793fb34e7104ab8edeeb3 Mon Sep 17 00:00:00 2001 From: David Mrva Date: Fri, 6 Nov 2020 18:29:57 +0000 Subject: [PATCH 4/6] fix code formatting --- pandas/core/frame.py | 6 ++++-- pandas/core/series.py | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 6d694c3e80a61..a318f8d181258 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -6032,7 +6032,8 @@ def __rdivmod__(self, other) -> Tuple[DataFrame, DataFrame]: # ---------------------------------------------------------------------- # Combination-Related - @doc(_shared_docs["compare"], + @doc( + _shared_docs["compare"], """ Returns ------- @@ -6134,7 +6135,8 @@ def __rdivmod__(self, other) -> Tuple[DataFrame, DataFrame]: 2 b b 3.0 3.0 3.0 4.0 3 b b NaN NaN 4.0 4.0 4 a a 5.0 5.0 5.0 5.0 -""", klass=_shared_doc_kwargs["klass"]) +""", + klass=_shared_doc_kwargs["klass"]) def compare( self, other: DataFrame, diff --git a/pandas/core/series.py b/pandas/core/series.py index 2e65aca0770c1..e915635561db6 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -2813,7 +2813,8 @@ def _construct_result( out.name = name return out - @doc(generic._shared_docs["compare"], + @doc( + generic._shared_docs["compare"], """ Returns ------- @@ -2873,7 +2874,8 @@ def _construct_result( 2 c c 3 d b 4 e e -""", klass=_shared_doc_kwargs["klass"]) +""", + klass=_shared_doc_kwargs["klass"]) def compare( self, other: "Series", From 0b184a12124b8e5c39c41646fb5164245add2314 Mon Sep 17 00:00:00 2001 From: David Mrva Date: Fri, 6 Nov 2020 19:15:36 +0000 Subject: [PATCH 5/6] fix code formatting --- pandas/core/frame.py | 3 ++- pandas/core/series.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index a318f8d181258..14183d822db91 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -6136,7 +6136,8 @@ def __rdivmod__(self, other) -> Tuple[DataFrame, DataFrame]: 3 b b NaN NaN 4.0 4.0 4 a a 5.0 5.0 5.0 5.0 """, - klass=_shared_doc_kwargs["klass"]) + klass=_shared_doc_kwargs["klass"] + ) def compare( self, other: DataFrame, diff --git a/pandas/core/series.py b/pandas/core/series.py index e915635561db6..6e0c4e3bf67a8 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -2875,7 +2875,8 @@ def _construct_result( 3 d b 4 e e """, - klass=_shared_doc_kwargs["klass"]) + klass=_shared_doc_kwargs["klass"] + ) def compare( self, other: "Series", From 156e39d02e115b6bc8326dffa5e9e67f445f1e87 Mon Sep 17 00:00:00 2001 From: David Mrva Date: Fri, 6 Nov 2020 19:25:40 +0000 Subject: [PATCH 6/6] fix code formatting --- pandas/core/frame.py | 2 +- pandas/core/series.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 14183d822db91..e9634bc3aabd6 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -6136,7 +6136,7 @@ def __rdivmod__(self, other) -> Tuple[DataFrame, DataFrame]: 3 b b NaN NaN 4.0 4.0 4 a a 5.0 5.0 5.0 5.0 """, - klass=_shared_doc_kwargs["klass"] + klass=_shared_doc_kwargs["klass"], ) def compare( self, diff --git a/pandas/core/series.py b/pandas/core/series.py index 6e0c4e3bf67a8..f6928c2179397 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -2875,7 +2875,7 @@ def _construct_result( 3 d b 4 e e """, - klass=_shared_doc_kwargs["klass"] + klass=_shared_doc_kwargs["klass"], ) def compare( self,