Skip to content

BUG: merge with CategoricalIndex for left_on/right_on #48464

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

Merged
merged 2 commits into from
Sep 9, 2022

Conversation

jbrockmendel
Copy link
Member

  • closes #xxxx (Replace xxxx with the Github issue number)
  • Tests added and passed if fixing a bug or adding a new feature
  • All code checks passed.
  • Added type annotations to new arguments/methods/functions.
  • Added an entry in the latest doc/source/whatsnew/vX.X.X.rst file if fixing a bug or adding a new feature.

right = DataFrame({"A": ci, "B": range(3)})
left = DataFrame({"C": range(3, 6)})

res = merge(left, right, left_on=ci, right_on="A")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the comment below the code change:

           # if either left or right is a categorical
            # then the must match exactly in categories & ordered

Apply here as well? Could you add a test where categories/ordered are different too?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

really shouldn't be relevant. its just a matter of CategoricalIndex vs Categorical

@mroeschke mroeschke added Reshaping Concat, Merge/Join, Stack/Unstack, Explode Categorical Categorical Data Type labels Sep 8, 2022
@mroeschke mroeschke added this to the 1.6 milestone Sep 9, 2022
@mroeschke mroeschke merged commit 1b2646a into pandas-dev:main Sep 9, 2022
@mroeschke
Copy link
Member

Thanks @jbrockmendel

@jbrockmendel jbrockmendel deleted the bug-merge-catindex branch September 9, 2022 17:04
@mroeschke mroeschke modified the milestones: 1.6, 2.0 Oct 13, 2022
noatamir pushed a commit to noatamir/pandas that referenced this pull request Nov 9, 2022
* BUG: merge with CategoricalIndex for left_on/right_on

* GH refs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Categorical Categorical Data Type Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants