-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
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
Changes from 3 commits
c077cab
1ec01b2
652bf23
62908e1
8630eee
ae5097b
0ec606b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3683,7 +3683,16 @@ def join(self, other, how="left", level=None, return_indexers=False, sort=False) | |
return self._join_non_unique( | ||
other, how=how, return_indexers=return_indexers | ||
) | ||
elif self.is_monotonic and other.is_monotonic: | ||
elif ( | ||
self.is_monotonic | ||
and other.is_monotonic | ||
and ( | ||
not isinstance(self, ABCMultiIndex) | ||
or not any(is_categorical_dtype(dtype) for dtype in self.dtypes) | ||
) | ||
): | ||
# Categorical is monotonic if data are ordered as categories, but join can | ||
# not handle this in case of not alphabetically monotonic GH#38502 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is alphabetical really the issue? what about numeric or dt64 Categoricals? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will add tests for different types of Categorical.s There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
try: | ||
return self._join_monotonic( | ||
other, how=how, return_indexers=return_indexers | ||
|
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 check _is_lexsorted instead rather than this specific check.
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.
Same issue as with is_monotonic, depends on the categories too.