From 90dc9aeebfad683b1f9792a228412861e9330f47 Mon Sep 17 00:00:00 2001 From: smartvinnetou <61093810+smartvinnetou@users.noreply.github.com> Date: Wed, 11 Nov 2020 01:26:37 +0000 Subject: [PATCH] replace Appender decorator with doc (#37384) * replace Appender decorator with doc * replaced Appender with doc for Frame.compare() and Series.compare() * fix a doc string format * fix code formatting * fix code formatting * fix code formatting Co-authored-by: David Mrva --- pandas/core/frame.py | 11 ++++++----- pandas/core/generic.py | 2 +- pandas/core/series.py | 7 ++++--- pandas/core/shared_docs.py | 6 +++--- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index af89adbad7dc0..9ce5ef2fc3cfe 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -6041,7 +6041,8 @@ def __rdivmod__(self, other) -> Tuple[DataFrame, DataFrame]: # ---------------------------------------------------------------------- # Combination-Related - @Appender( + @doc( + _shared_docs["compare"], """ Returns ------- @@ -6071,11 +6072,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 @@ -6143,9 +6144,9 @@ 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"], ) - @Appender(_shared_docs["compare"] % _shared_doc_kwargs) def compare( self, other: DataFrame, diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 255c45d5a45aa..317bdb1fcc797 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -8597,7 +8597,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/series.py b/pandas/core/series.py index c5df6a9298c88..f243771ff97a5 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -2813,7 +2813,8 @@ def _construct_result( out.name = name return out - @Appender( + @doc( + generic._shared_docs["compare"], """ Returns ------- @@ -2873,9 +2874,9 @@ def _construct_result( 2 c c 3 d b 4 e e -""" +""", + klass=_shared_doc_kwargs["klass"], ) - @Appender(generic._shared_docs["compare"] % _shared_doc_kwargs) def compare( self, other: "Series", 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