Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: add suffixes argument to DataFrame.compare #44354

Closed
erfannariman opened this issue Nov 8, 2021 · 2 comments · Fixed by #47643
Closed

ENH: add suffixes argument to DataFrame.compare #44354

erfannariman opened this issue Nov 8, 2021 · 2 comments · Fixed by #47643
Labels
Enhancement Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Milestone

Comments

@erfannariman
Copy link
Member

erfannariman commented Nov 8, 2021

Is your feature request related to a problem?

It would be convenient to choose other suffixes in DataFrame.compare than self, other

Describe the solution you'd like

Add argument suffixes so users can specify them.

API breaking implications

None

Additional context

df = pd.DataFrame(
    {"col1": ["a", "b", "c"], "col2": [1.0, 2.0, np.nan], "col3": [1.0, 2.0, 3.0]},
    columns=["col1", "col2", "col3"],
)
df2 = df.copy()
df2.loc[0, "col1"] = "c"
df2.loc[2, "col3"] = np.nan
diff = df.compare(df2, suffixes=["left", "right"])
print(diff)

  col1       col3      
  left right left right
0    a     c  NaN   NaN
2  NaN   NaN  3.0   NaN
@erfannariman erfannariman added Enhancement Needs Triage Issue that has not been reviewed by a pandas team member labels Nov 8, 2021
@jreback jreback added Reshaping Concat, Merge/Join, Stack/Unstack, Explode and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Nov 9, 2021
@jreback jreback added this to the Contributions Welcome milestone Nov 9, 2021
@jreback
Copy link
Contributor

jreback commented Nov 9, 2021

seems reasonable

@Runningwater23
Copy link

In the source code, suffixes is fixed to keys=['self', 'other'], change the value of keys to the value of suffixes transferred by the user.

ahmedibrhm added a commit to ahmedibrhm/pandas that referenced this issue Jul 8, 2022
@jreback jreback modified the milestones: Contributions Welcome, 1.5 Jul 8, 2022
phofl pushed a commit that referenced this issue Jul 16, 2022
* DOC #45443 edited the documentation of where/mask functions

* DOC #45443 edited the documentation of where/mask functions

* Update generic.py

* ENH: add suffixes argument to DataFrame.compare #44354

* Edited the tests

* space fixing

* Update shared_docs.py

* Update series.py

* Update series.py

* invalid argument tests

* issue reference

* syntax editing

* grammar fixing

* edit doc

* editting doc

* Update 02_read_write.rst

* Update 02_read_write.rst

* Update v1.5.0.rst

* Update v1.5.0.rst

* np

* 1.5.0 rst

* created tests for invalid input

* space

* space

* space

* editing test
mroeschke pushed a commit that referenced this issue Aug 1, 2022
…nt (#47761)

* DOC #45443 edited the documentation of where/mask functions

* DOC #45443 edited the documentation of where/mask functions

* Update generic.py

* ENH: add suffixes argument to DataFrame.compare #44354

* Edited the tests

* space fixing

* Update shared_docs.py

* Update series.py

* Update series.py

* invalid argument tests

* issue reference

* syntax editing

* grammar fixing

* edit doc

* editting doc

* Update 02_read_write.rst

* Update 02_read_write.rst

* Update v1.5.0.rst

* Update v1.5.0.rst

* np

* 1.5.0 rst

* created tests for invalid input

* space

* space

* space

* editing test

* deprecated

* syntax

* editting existed examples

* syntax

* edit past tests

* editting pivot

* ex

* editing internal use

* pivot

* warning expected

* warning

* ignore doc warning

* doc

* tests

* ignore warning

* test

* plotting

* test

* doc

* doc

* white space

* doc

* doc

* doc

* doc

* stacklevel

* pivot

* pivot

* cookbook

* flake8

* flake8

* what's new

* syntax

* itr

* car names

* test edit

* fixing tests

* fixing tests

* flake8

* rst edit

* __iter__ edit

* flake8

* flake8

* space

* test

* merge

* ignore the type

* mypy

* type

* self.keys

* tests

* .

* .

* adding keys

* order

* attribute

* ignores

* Update hist.py

* ignore

* .

* .

* .

* .

* .

* Update doc/source/whatsnew/v1.5.0.rst

Co-authored-by: Richard Shadrach <45562402+rhshadrach@users.noreply.github.com>

Co-authored-by: Richard Shadrach <45562402+rhshadrach@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Projects
None yet
3 participants