Skip to content

BUG: join not working correctly with MultiIndex and one dimension categorical #38621

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 7 commits into from
Jan 13, 2021

Conversation

phofl
Copy link
Member

@phofl phofl commented Dec 21, 2020

@phofl phofl added Categorical Categorical Data Type Reshaping Concat, Merge/Join, Stack/Unstack, Explode labels Dec 21, 2020
)
):
# Categorical is monotonic if data are ordered as categories, but join can
# not handle this in case of not alphabetically monotonic GH#38502
Copy link
Member

Choose a reason for hiding this comment

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

is alphabetical really the issue? what about numeric or dt64 Categoricals?

Copy link
Member Author

Choose a reason for hiding this comment

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

Hm bad wording probably. If the object is lexicographically ordered everything is fine. Monotonic in the sense of categorical monotonic is the problem

Copy link
Member Author

Choose a reason for hiding this comment

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

I will add tests for different types of Categorical.s

Copy link
Member Author

@phofl phofl Dec 24, 2020

Choose a reason for hiding this comment

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

Added float, int and timestamps.

Edit: They are all failling without the changes

self.is_monotonic
and other.is_monotonic
and (
not isinstance(self, ABCMultiIndex)
Copy link
Contributor

Choose a reason for hiding this comment

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

can you check _is_lexsorted instead rather than this specific check.

Copy link
Member Author

Choose a reason for hiding this comment

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

Same issue as with is_monotonic, depends on the categories too.

@jreback jreback added this to the 1.3 milestone Jan 13, 2021
@jreback jreback merged commit a97d90a into pandas-dev:master Jan 13, 2021
@jreback
Copy link
Contributor

jreback commented Jan 13, 2021

thanks @phofl

@phofl phofl deleted the 38502 branch January 13, 2021 16:55
luckyvs1 pushed a commit to luckyvs1/pandas that referenced this pull request Jan 20, 2021
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.

BUG: Incomplete join with categorical MultiIndex
3 participants