Skip to content

ENH: Add lsuffix=/rsuffix= kwargs to pd.merge() and df.merge() #46046

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

Open
wany-oh opened this issue Feb 18, 2022 · 3 comments
Open

ENH: Add lsuffix=/rsuffix= kwargs to pd.merge() and df.merge() #46046

wany-oh opened this issue Feb 18, 2022 · 3 comments
Labels
API - Consistency Internal Consistency of API/Behavior Deprecate Functionality to remove in pandas Enhancement Needs Discussion Requires discussion from core team before further action Reshaping Concat, Merge/Join, Stack/Unstack, Explode

Comments

@wany-oh
Copy link
Contributor

wany-oh commented Feb 18, 2022

It's weird that it's in join() but not in merge(), and the current behavior (passing the length-2 list-like) of suffixes= kwarg is somewhat confusing syntactically.

expected:

>>> df1 = pd.DataFrame({"lkey": ["foo", "bar", "baz", "foo"], "value": [1, 2, 3, 5]})
>>> df2 = pd.DataFrame({"rkey": ["foo", "bar", "baz", "foo"], "value": [5, 6, 7, 8]})

>>> df1.merge(df2, left_on="lkey", right_on="rkey", lsuffix="_left", rsuffix="_right")
  lkey  value_left rkey  value_right
0  foo           1  foo            5
1  foo           1  foo            8
2  foo           5  foo            5
3  foo           5  foo            8
4  bar           2  bar            6
5  baz           3  baz            7
@wany-oh wany-oh added Enhancement Needs Triage Issue that has not been reviewed by a pandas team member labels Feb 18, 2022
@rhshadrach
Copy link
Member

Agreed it's not ideal that the syntax is different between the two, but I'm fairly negative on going through a deprecation on this, at least at this time. There are any argument outside of personal opinion as to which syntax is better?

@rhshadrach rhshadrach added Reshaping Concat, Merge/Join, Stack/Unstack, Explode API - Consistency Internal Consistency of API/Behavior labels Feb 24, 2022
@jreback
Copy link
Contributor

jreback commented Feb 24, 2022

pd.merge is the more general case (and likely more used than join)

so i think we should unify these
args

+1 on deprecation of lsuffix / rsuffix
in favor of suffixes

@wany-oh
Copy link
Contributor Author

wany-oh commented Feb 25, 2022

Agreed it's not ideal that the syntax is different between the two, but I'm fairly negative on going through a deprecation on this, at least at this time. There are any argument outside of personal opinion as to which syntax is better?

As you said, it depends on personal preference as to which is better.
So, on the contrary, some people may say that the suffixes= argument should be added to join().

In addition, I am not saying that the current argument should be deprecated.

@mroeschke mroeschke added Deprecate Functionality to remove in pandas and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Mar 16, 2022
@rhshadrach rhshadrach added the Needs Discussion Requires discussion from core team before further action label Jun 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API - Consistency Internal Consistency of API/Behavior Deprecate Functionality to remove in pandas Enhancement Needs Discussion Requires discussion from core team before further action Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Projects
None yet
Development

No branches or pull requests

4 participants