-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Deprecate suffixes in merge producing duplicate columns #40991
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed; deprecation of this behavior is easier to maintain as opposed to adding a new param
left = DataFrame({"a": [1, 2, 3], "b": 1, "b_x": 2}) | ||
right = DataFrame({"a": [1, 2, 3], "b": 2}) | ||
with tm.assert_produces_warning(FutureWarning): | ||
merge(left, right, on="a") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you assert the results here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done and added another test
left = DataFrame([[1, 1, 1], [2, 2, 2]], columns=["a", "b", "b"]) | ||
right = DataFrame({"a": [1, 3], "b": 2}) | ||
result = merge(left, right, on="a") | ||
expected = DataFrame([[1, 1, 1, 2]], columns=["a", "b_x", "b_x", "b_y"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this the expected result?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I wanted to avoid raising when we already get duplicate columns as input, because the collisions in this case are not caused by the suffixes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kk, can you add a comment to this effect
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do.
thanks @phofl |
I think we should not allow these column collisions at all. Hence deprecating and raising in 2.0
Alternative here would be to add an
errors
keyword to the merge and join functions as @simonjayhawkins mentioned in the op.