-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
BUG: DataFrame.drop raising TypeError when passing empty DatetimeIndex/list #28114
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 all commits
3bf7b26
53566f6
36d19f7
f32ed62
3d7045c
02bb501
7009e2f
25bf949
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 |
---|---|---|
|
@@ -3916,6 +3916,9 @@ def drop( | |
|
||
for axis, labels in axes.items(): | ||
if labels is not None: | ||
# Check for empty Index, GH 27994 | ||
if is_list_like(labels) and not len(labels): | ||
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. rather than do this, you can just handle the empty case in 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. Are you sure @jreback? I tried a little, but I couldn't get it work while making sure to raise 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 think the suggestion is to include the 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. can you try this |
||
continue | ||
obj = obj._drop_axis(labels, axis, level=level, errors=errors) | ||
|
||
if inplace: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4720,6 +4720,10 @@ def get_indexer_non_unique(self, target): | |
return pself.get_indexer_non_unique(ptarget) | ||
|
||
if self.is_all_dates: | ||
# If `target` doesn't consist of dates, `target.asi8` will return | ||
# None, which will raise TypeError. GH 27994 | ||
if not target.is_all_dates: | ||
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. this likely is not necessary if you implemented as per my comment above 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. When passing 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. What exception do you get without this? |
||
raise KeyError("{} not found in axis".format(target.to_numpy())) | ||
tgt_values = target.asi8 | ||
else: | ||
tgt_values = target._ndarray_values | ||
|
Uh oh!
There was an error while loading. Please reload this page.