-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
REGR: drop raising with ea index and duplicates #45983
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
Conversation
pandas/core/generic.py
Outdated
@@ -4342,6 +4342,9 @@ def _drop_axis( | |||
if errors == "raise" and labels_missing: | |||
raise KeyError(f"{labels} not found in axis") | |||
|
|||
if is_extension_array_dtype(mask.dtype): | |||
mask = mask.to_numpy() |
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.
if mask is BooleanArray, then we need to specify dtype=bool otherwise we get object dtype here. or could implement EA.nonzero.
comment with GH ref?
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.
Thx added the dtype and comment. I must have removed the dtype somehow after fixing this
def test_drop_index_ea_dtype(self, any_numeric_ea_dtype, idx, level): | ||
# GH#45860 | ||
df = DataFrame( | ||
{"a": [1, 2, 2], "b": 100}, dtype=any_numeric_ea_dtype |
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.
case with a pd.NA?
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.
Added one more element, but this should not matter in this case I think
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.
the case i had in mind is where the BooleanArray mask that this PR casts to ndarray contains a pd.NA. Is that not reachable?
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.
Ah got you. I don't think so no. Having NA on both sides evaluates to False. Added the case
if is_extension_array_dtype(mask.dtype): | ||
# GH#45860 | ||
mask = mask.to_numpy(dtype=bool) | ||
|
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.
i guess we maybe want to define .nonzero()
on EA arrays
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.
+1
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.
opened #46025
@meeseeksdev backport 1.4.x |
Something went wrong ... Please have a look at my logs. |
…46020) Co-authored-by: Patrick Hoefler <[email protected]>
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.We handle this case similarly for loc