-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: reindex would throw when a categorical index was empty #16770 #16820
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 14 commits
3092bbc
69454ec
0a20024
0645868
8f8e3d6
a725fbf
800b40d
5362447
59b17cd
26e1a60
9ed80f0
6e8f1b3
7acc09f
eab3192
83fd749
1f2865e
9802288
0e2d315
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 |
---|---|---|
|
@@ -419,7 +419,11 @@ def reindex(self, target, method=None, level=None, limit=None, | |
raise ValueError("cannot reindex with a non-unique indexer") | ||
|
||
indexer, missing = self.get_indexer_non_unique(np.array(target)) | ||
new_target = self.take(indexer) | ||
|
||
if len(self.codes): | ||
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. if len(indexer) 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. In the case the target is [1] say and the categorical index is empty then indexer here will be [-1] so not empty. The error occurs when try to run take on the empty underlying index. 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. right its missing, so ok then. |
||
new_target = self.take(indexer) | ||
else: | ||
new_target = target | ||
|
||
# filling in missing if needed | ||
if len(missing): | ||
|
@@ -430,7 +434,6 @@ def reindex(self, target, method=None, level=None, limit=None, | |
result = Index(np.array(self), name=self.name) | ||
new_target, indexer, _ = result._reindex_non_unique( | ||
np.array(target)) | ||
|
||
else: | ||
|
||
codes = new_target.codes.copy() | ||
|
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.
revert this whatsnew note