Skip to content

Commit 90dc9ae

Browse files
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 <[email protected]>
1 parent e480a44 commit 90dc9ae

File tree

4 files changed

+14
-12
lines changed

4 files changed

+14
-12
lines changed

pandas/core/frame.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -6041,7 +6041,8 @@ def __rdivmod__(self, other) -> Tuple[DataFrame, DataFrame]:
60416041
# ----------------------------------------------------------------------
60426042
# Combination-Related
60436043

6044-
@Appender(
6044+
@doc(
6045+
_shared_docs["compare"],
60456046
"""
60466047
Returns
60476048
-------
@@ -6071,11 +6072,11 @@ def __rdivmod__(self, other) -> Tuple[DataFrame, DataFrame]:
60716072
Examples
60726073
--------
60736074
>>> df = pd.DataFrame(
6074-
... {
6075+
... {{
60756076
... "col1": ["a", "a", "b", "b", "a"],
60766077
... "col2": [1.0, 2.0, 3.0, np.nan, 5.0],
60776078
... "col3": [1.0, 2.0, 3.0, 4.0, 5.0]
6078-
... },
6079+
... }},
60796080
... columns=["col1", "col2", "col3"],
60806081
... )
60816082
>>> df
@@ -6143,9 +6144,9 @@ def __rdivmod__(self, other) -> Tuple[DataFrame, DataFrame]:
61436144
2 b b 3.0 3.0 3.0 4.0
61446145
3 b b NaN NaN 4.0 4.0
61456146
4 a a 5.0 5.0 5.0 5.0
6146-
"""
6147+
""",
6148+
klass=_shared_doc_kwargs["klass"],
61476149
)
6148-
@Appender(_shared_docs["compare"] % _shared_doc_kwargs)
61496150
def compare(
61506151
self,
61516152
other: DataFrame,

pandas/core/generic.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8597,7 +8597,7 @@ def ranker(data):
85978597

85988598
return ranker(data)
85998599

8600-
@Appender(_shared_docs["compare"] % _shared_doc_kwargs)
8600+
@doc(_shared_docs["compare"], klass=_shared_doc_kwargs["klass"])
86018601
def compare(
86028602
self,
86038603
other,

pandas/core/series.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -2813,7 +2813,8 @@ def _construct_result(
28132813
out.name = name
28142814
return out
28152815

2816-
@Appender(
2816+
@doc(
2817+
generic._shared_docs["compare"],
28172818
"""
28182819
Returns
28192820
-------
@@ -2873,9 +2874,9 @@ def _construct_result(
28732874
2 c c
28742875
3 d b
28752876
4 e e
2876-
"""
2877+
""",
2878+
klass=_shared_doc_kwargs["klass"],
28772879
)
2878-
@Appender(generic._shared_docs["compare"] % _shared_doc_kwargs)
28792880
def compare(
28802881
self,
28812882
other: "Series",

pandas/core/shared_docs.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,16 @@
4747
_shared_docs[
4848
"compare"
4949
] = """
50-
Compare to another %(klass)s and show the differences.
50+
Compare to another {klass} and show the differences.
5151
5252
.. versionadded:: 1.1.0
5353
5454
Parameters
5555
----------
56-
other : %(klass)s
56+
other : {klass}
5757
Object to compare with.
5858
59-
align_axis : {0 or 'index', 1 or 'columns'}, default 1
59+
align_axis : {{0 or 'index', 1 or 'columns'}}, default 1
6060
Determine which axis to align the comparison on.
6161
6262
* 0, or 'index' : Resulting differences are stacked vertically

0 commit comments

Comments
 (0)