-
-
Notifications
You must be signed in to change notification settings - Fork 19.3k
BUG: index.getitem raising ValueError with boolean indexer and NA #45985
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
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 |
|---|---|---|
|
|
@@ -76,3 +76,11 @@ def test_get_loc_nan_object_dtype_nonmonotonic_nonunique(self): | |
| # we don't match at all on mismatched NA | ||
| with pytest.raises(KeyError, match="NaT"): | ||
| idx.get_loc(NaT) | ||
|
|
||
|
|
||
| def test_getitem_boolean_ea_indexer(): | ||
| # GH#45806 | ||
| ser = pd.Series([True, False, pd.NA], dtype="boolean") | ||
| result = ser.index[ser] | ||
| expected = Index([0]) | ||
|
Member
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 there a discussion where it was decided that this is the correct behavior? could plausibly raise. could also use ser._values or Index(ser) for the key?
Member
Author
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 works for a regular bool series, so thought that this should work too. We can add these test cases too, but if Series should work we have to keep that one
Member
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. @phofl just so im clear, your comment is responding to the "could also use..." part of mine? If so that's fine. I'm unclear on the other part of why we're not raising on pd.NA
Member
Author
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. Ah now I got you. Why should we raise on
Member
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 of |
||
| tm.assert_index_equal(result, expected) | ||
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.
clearer or more performant to do
isinstance(key, ExtensionArray)?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.
Thought about this too, but does not work unfortunately, since key is a Series here