-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
REGR: isin with nullable types with missing values raising #42473
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
jreback
merged 15 commits into
pandas-dev:master
from
mzeitlin11:regr_isin_extension_types
Jul 14, 2021
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
d9132d7
Push for testing asv fix
mzeitlin11 1902d7a
Add tests and whatsnew
mzeitlin11 d2b988d
Comment fixups
mzeitlin11 e60c0d4
Fix benchmark
mzeitlin11 e902218
Fix benchmark
mzeitlin11 814f978
Fix benchmark
mzeitlin11 0a9b4e6
Move has_na, change import
mzeitlin11 6a68490
Only check NA for object
mzeitlin11 44bcd67
Update benchmark to make allowed clearer
mzeitlin11 821c6b6
Merge branch 'master' into regr_isin_extension_types
jreback 893343f
Merge remote-tracking branch 'upstream/master' into regr_isin_extensi…
mzeitlin11 e7b66b7
Simpler benchmark fix
mzeitlin11 3cfe98e
Simpler benchmark fix
mzeitlin11 ec61ab1
Merge remote-tracking branch 'upstream/master' into regr_isin_extensi…
mzeitlin11 17a50b9
Handle in python space
mzeitlin11 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -403,12 +403,20 @@ def isin(self, values) -> BooleanArray: # type: ignore[override] | |
|
||
from pandas.core.arrays import BooleanArray | ||
|
||
result = isin(self._data, values) | ||
# algorithms.isin will eventually convert values to an ndarray, so no extra | ||
# cost to doing it here first | ||
values_arr = np.asarray(values) | ||
result = isin(self._data, values_arr) | ||
|
||
if self._hasna: | ||
if libmissing.NA in values: | ||
result += self._mask | ||
else: | ||
result *= np.invert(self._mask) | ||
values_have_NA = is_object_dtype(values_arr.dtype) and any( | ||
val is self.dtype.na_value for val in values_arr | ||
) | ||
|
||
# For now, NA does not propagate so set result according to presence of NA, | ||
# see https://github.com/pandas-dev/pandas/pull/38379 for some discussion | ||
result[self._mask] = values_have_NA | ||
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 line should be equivalent to the deleted if/else AFAICT, but I think makes logic easier to follow |
||
|
||
mask = np.zeros_like(self, dtype=bool) | ||
return BooleanArray(result, mask, copy=False) | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.