Skip to content

API: Index.__cmp__(Series) return NotImplemented #37160

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

Closed

Conversation

jbrockmendel
Copy link
Member

@jbrockmendel jbrockmendel commented Oct 16, 2020

Gets rid of an unnecessary special case.

Could do this as a deprecation first.

@@ -744,11 +744,13 @@ def test_dti_cmp_tdi_tzawareness(self, other):

result = dti == other
expected = np.array([False] * 10)
tm.assert_numpy_array_equal(result, expected)
if isinstance(other, Series):
Copy link
Contributor

Choose a reason for hiding this comment

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

so this is technically a small api change? e.g. a dti == Series will now give a boolean Series? do we do this 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.

API change, yes. not just DTI, but any index == series will now return a Series[bool] instead of ndarray[bool]

Copy link
Contributor

Choose a reason for hiding this comment

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

hmm then i am no sure I like this api change. We return bool ndarrays on purpose from comparisions to avoid having to align everything. I think this could potentially be a nasty user trap.

Is there a reason you want to do this (aside from reconciling / cleaning).

Copy link
Member Author

Choose a reason for hiding this comment

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

My motivation is pretty much "hunt down special cases"

IIRC @jorisvandenbossche mentioned a ways back that the existing behavior is from a time before series[bool_dtypes_series] was supported, but i could be off on that

@jreback jreback added API - Consistency Internal Consistency of API/Behavior Index Related to the Index class or subclasses labels Oct 17, 2020
@jbrockmendel
Copy link
Member Author

if this isnt something we want to do, can close

@jbrockmendel
Copy link
Member Author

Discussed on Nov 2020 dev call, decided to put this off until we have BoolIndex

@jbrockmendel jbrockmendel deleted the depr-index-defer-cmp branch November 11, 2020 19:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API - Consistency Internal Consistency of API/Behavior Index Related to the Index class or subclasses
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DEPR: Index == Series should return NotImplemented
2 participants