-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: isin fails to correctly compare None values. #41145
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
22e7759
8659146
0a59055
27cbd60
d79e68a
4415065
faea64b
88ab9c5
17f670a
42dfe2d
139f33a
db96a41
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 | ||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -157,17 +157,19 @@ def vec_compare(ndarray[object] left, ndarray[object] right, object op) -> ndarr | |||||||||||||||||||||||||||
for i in range(n): | ||||||||||||||||||||||||||||
x = left[i] | ||||||||||||||||||||||||||||
y = right[i] | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
if checknull(x) or checknull(y): | ||||||||||||||||||||||||||||
if x is None and y is None: | ||||||||||||||||||||||||||||
result[i] = False | ||||||||||||||||||||||||||||
elif checknull(x) or checknull(y): | ||||||||||||||||||||||||||||
result[i] = True | ||||||||||||||||||||||||||||
else: | ||||||||||||||||||||||||||||
result[i] = PyObject_RichCompareBool(x, y, flag) | ||||||||||||||||||||||||||||
else: | ||||||||||||||||||||||||||||
for i in range(n): | ||||||||||||||||||||||||||||
x = left[i] | ||||||||||||||||||||||||||||
y = right[i] | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
if checknull(x) or checknull(y): | ||||||||||||||||||||||||||||
if x is None and y is None: | ||||||||||||||||||||||||||||
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 is contrary to what we do with nulls generally, does anything break when you make this change (only)? 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. AFAIK, this does not break any tests. However, I am starting to think that #35565 is not actually a bug, but intended behavior. From the docs: "One has to be mindful that in Python (and NumPy), the nan's don’t compare equal, but None's do. Note that pandas/NumPy uses the fact that np.nan != np.nan, and treats None like np.nan." I see the same behavior in Lines 74 to 86 in 1269bc6
I found this related issue: #34975 Should we close this PR and the issue, then? |
||||||||||||||||||||||||||||
result[i] = True | ||||||||||||||||||||||||||||
elif checknull(x) or checknull(y): | ||||||||||||||||||||||||||||
result[i] = False | ||||||||||||||||||||||||||||
else: | ||||||||||||||||||||||||||||
result[i] = PyObject_RichCompareBool(x, y, flag) | ||||||||||||||||||||||||||||
|
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.
this is superfluous as checknull already checks None
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.
Yep, this was incorrect. Changed.
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.
what was incorrect?
rule of thumb: let the question-asker mark the conversation as resolved