diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 049d2c4888a69..e9634bc3aabd6 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -6032,7 +6032,8 @@ def __rdivmod__(self, other) -> Tuple[DataFrame, DataFrame]: # ---------------------------------------------------------------------- # Combination-Related - @Appender( + @doc( + _shared_docs["compare"], """ Returns ------- @@ -6062,11 +6063,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 @@ -6134,9 +6135,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 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/series.py b/pandas/core/series.py index e4a805a18bcdb..f6928c2179397 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