Skip to content

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

Merged
merged 4 commits into from
Jul 8, 2022

Conversation

phofl
Copy link
Member

@phofl phofl commented Jul 7, 2022

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

@@ -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):
Copy link
Member

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?

Copy link
Member

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree here

Copy link
Member

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switched to indexer

@mroeschke mroeschke added Indexing Related to indexing on series/frames, not to indexes themselves Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate NA - MaskedArrays Related to pd.NA and nullable extension arrays labels Jul 7, 2022
@jreback jreback added this to the 1.5 milestone Jul 8, 2022
Copy link
Member

@mroeschke mroeschke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jreback jreback merged commit 2367feb into pandas-dev:main Jul 8, 2022
@jreback
Copy link
Contributor

jreback commented Jul 8, 2022

thanks @phofl

@phofl phofl deleted the 46551 branch July 9, 2022 02:12
yehoshuadimarsky pushed a commit to yehoshuadimarsky/pandas that referenced this pull request Jul 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Indexing Related to indexing on series/frames, not to indexes themselves Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate NA - MaskedArrays Related to pd.NA and nullable extension arrays
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: Unexpected IndexingError when filtering with .loc
4 participants