-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: boolean indexer with NA raising when reindex is necessary #47623
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/indexing.py
Outdated
@@ -2531,6 +2532,9 @@ def check_bool_indexer(index: Index, key) -> np.ndarray: | |||
""" | |||
result = key | |||
if isinstance(key, ABCSeries) and not key.index.equals(index): | |||
if is_extension_array_dtype(result): |
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 think checking the indexer approach may be more robust here instead. Would this hit 3rd party EA dtypes and _mask
may not be defined?
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.
Not sure if this hit in a code path where ExtensionDtype._is_boolean = True
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.
agree here
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.
Also much more performant to check result.dtype than just result
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.
Switched to indexer
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.
LGTM cc @jbrockmendel @jreback
thanks @phofl |
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.There are multiple options how to solve this. Alternatively, we could get the indexeer for the reindexing operation and check for -1 instead of filling the NAs