-
-
Notifications
You must be signed in to change notification settings - Fork 18.3k
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
REGR: Fix nan comparison for same Index object #47326
Conversation
pandas/core/indexes/base.py
Outdated
@@ -6955,7 +6955,7 @@ def _cmp_method(self, other, op): | |||
# TODO: should set MultiIndex._can_hold_na = False? | |||
arr[self.isna()] = False | |||
return arr | |||
elif op in {operator.ne, operator.lt, operator.gt}: | |||
elif op == operator.ne: |
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.
is?
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.
Was not sure about it, but it does get hit through !=
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.
quickly scanning the code, it appears we mostly use is
elsewhere
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.
Thx, will change
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.
done
pandas/tests/indexes/test_base.py
Outdated
@@ -1604,3 +1604,15 @@ def test_get_attributes_dict_deprecated(): | |||
with tm.assert_produces_warning(DeprecationWarning): | |||
attrs = idx._get_attributes_dict() | |||
assert attrs == {"name": None} | |||
|
|||
|
|||
def test_nan_comparison_same_object(): |
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 test gt as well as lt; this doesn't affect le, ge right?
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.
Done and no, they are checked i a different if block
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.
thanks @phofl lgtm.
thanks @phofl |
@meeseeksdev backport 1.4.x |
Could not push to auto-backport-of-pr-47326-on-1.4.x due to error, aborting. |
… Index object) (#47364) Backport PR #47326: REGR: Fix nan comparison for same Index object Co-authored-by: Patrick Hoefler <[email protected]>
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.