Skip to content

Commit

Permalink
replace Appender decorator with doc (#37384)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
smartvinnetou and davidmspeechmatics authored Nov 11, 2020
1 parent e480a44 commit 90dc9ae
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
11 changes: 6 additions & 5 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -6041,7 +6041,8 @@ def __rdivmod__(self, other) -> Tuple[DataFrame, DataFrame]:
# ----------------------------------------------------------------------
# Combination-Related

@Appender(
@doc(
_shared_docs["compare"],
"""
Returns
-------
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 4 additions & 3 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -2813,7 +2813,8 @@ def _construct_result(
out.name = name
return out

@Appender(
@doc(
generic._shared_docs["compare"],
"""
Returns
-------
Expand Down Expand Up @@ -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",
Expand Down
6 changes: 3 additions & 3 deletions pandas/core/shared_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 90dc9ae

Please sign in to comment.