Skip to content
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

Merged
merged 3 commits into from
Jun 15, 2022
Merged

Conversation

phofl
Copy link
Member

@phofl phofl commented Jun 13, 2022

@phofl phofl added Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Regression Functionality that used to work in a prior pandas version Index Related to the Index class or subclasses labels Jun 13, 2022
@phofl phofl added this to the 1.4.3 milestone Jun 13, 2022
@@ -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:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is?

Copy link
Member Author

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 !=

Copy link
Member

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx, will change

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -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():
Copy link
Contributor

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?

Copy link
Member Author

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

Copy link
Member

@simonjayhawkins simonjayhawkins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @phofl lgtm.

@jreback jreback merged commit 7310d90 into pandas-dev:main Jun 15, 2022
@jreback
Copy link
Contributor

jreback commented Jun 15, 2022

thanks @phofl

@jreback
Copy link
Contributor

jreback commented Jun 15, 2022

@meeseeksdev backport 1.4.x

meeseeksmachine pushed a commit to meeseeksmachine/pandas that referenced this pull request Jun 15, 2022
@lumberbot-app
Copy link

lumberbot-app bot commented Jun 15, 2022

Could not push to auto-backport-of-pr-47326-on-1.4.x due to error, aborting.

@phofl phofl deleted the 47105 branch June 15, 2022 11:43
simonjayhawkins pushed a commit that referenced this pull request Jun 15, 2022
… Index object) (#47364)

Backport PR #47326: REGR: Fix nan comparison for same Index object

Co-authored-by: Patrick Hoefler <[email protected]>
yehoshuadimarsky pushed a commit to yehoshuadimarsky/pandas that referenced this pull request Jul 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Index Related to the Index class or subclasses Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Regression Functionality that used to work in a prior pandas version
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: nan comparisons behave differently on identical objects
3 participants