Skip to content

Add parameter always_suffix to DataFrame.merge #18260

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

Closed
lverweijen opened this issue Nov 13, 2017 · 1 comment
Closed

Add parameter always_suffix to DataFrame.merge #18260

lverweijen opened this issue Nov 13, 2017 · 1 comment
Labels
API Design Duplicate Report Duplicate issue or pull request Reshaping Concat, Merge/Join, Stack/Unstack, Explode

Comments

@lverweijen
Copy link

Code Sample

A = pd.DataFrame({'a': [1, 2, 3], 'b': [4, 5, 6]})
B = pd.DataFrame({'a': [1, 2, 3], 'c': [7, 8, 9]})

def foo(A, B):
    C = A.merge(B, on=['a'])
    C['c']  # Where does c originate from?

Problem description

There is no way to explicitely specificy whether 'c' originates from A or B. This makes code harder to maintain. Better would be if I could write something like:

C = A.merge(B, on=['a'], always_suffix=True)
C['c_y]  # Obvious that C comes from B, because suffixes are always created
@jreback
Copy link
Contributor

jreback commented Nov 13, 2017

this is a dupe of #17834

@jreback jreback closed this as completed Nov 13, 2017
@jreback jreback added API Design Duplicate Report Duplicate issue or pull request Reshaping Concat, Merge/Join, Stack/Unstack, Explode labels Nov 13, 2017
@jreback jreback added this to the No action milestone Nov 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Design Duplicate Report Duplicate issue or pull request Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Projects
None yet
Development

No branches or pull requests

2 participants