-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: equals/assert_numpy_array_equals with non-singleton NAs #39650
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
jbrockmendel
commented
Feb 7, 2021
- closes #xxxx
- tests added / passed
- Ensure all linting tests pass, see here for how to run them
- whatsnew entry
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.
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.
Does this change behaviour of how NA-likes are currently handled in equals
and assert methods?
Eg currently we have see None or np.nan as equivalent:
In [54]: pd.Series([1, None], dtype=object).equals(pd.Series([1, np.nan], dtype=object))
Out[54]: True
right = Series([np.float64("NaN")], dtype=object) | ||
assert left.equals(right) | ||
assert Index(left).equals(Index(right)) | ||
assert left.array.equals(right.array) |
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.
Can you also add tests for the case of non-matching NAs?
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.
sure
good catch, this changes that. will update to keep current behavior (though id be OK with deprecating it separately) |
pandas/_libs/lib.pyx
Outdated
(x is None or is_nan(x)) and (y is None or is_nan(y))): | ||
elif not ( | ||
PyObject_RichCompareBool(x, y, Py_EQ) | ||
or is_matching_na(x, y) |
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.
instead of this an you add a keyword to is_matching_na? (actually would make it easier to deprecate then), maybe allow_equivalent=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.
sure
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.
updated + greenish
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.
Does this need a whatsnew?
whatsnew added + green |