Skip to content

Fix series with none equals float series #44195

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
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pandas/_libs/missing.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ cpdef bint is_matching_na(object left, object right, bint nan_matches_none=False
elif left is NaT:
return right is NaT
elif util.is_float_object(left):
if nan_matches_none and right is None:
if nan_matches_none and right is None and util.is_nan(left):
return True
return (
util.is_nan(left)
Expand Down
8 changes: 8 additions & 0 deletions pandas/tests/series/methods/test_equals.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,11 @@ def test_equals_none_vs_nan():
assert ser.equals(ser2)
assert Index(ser, dtype=ser.dtype).equals(Index(ser2, dtype=ser2.dtype))
assert ser.array.equals(ser2.array)


def test_equals_None_vs_float():
left = Series([-np.inf, np.nan, -1.0, 0.0, 1.0, 10 / 3, np.inf], dtype=object)
right = Series([None] * len(left))

assert not left.equals(right)
assert not right.equals(left)