Skip to content

BUG: Index with tuples comparison not working anymore #34123

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
charlesdong1991 opened this issue May 11, 2020 · 6 comments · Fixed by #34137
Closed

BUG: Index with tuples comparison not working anymore #34123

charlesdong1991 opened this issue May 11, 2020 · 6 comments · Fixed by #34137
Assignees
Labels
Blocker Blocking issue or pull request for an upcoming release Bug Index Related to the Index class or subclasses
Milestone

Comments

@charlesdong1991
Copy link
Member

charlesdong1991 commented May 11, 2020

It seems trace back to #34081

with Index we could do something like:

>>> pd.Index(['a', 'b', 'c']) == 'c'
array([False, False,  True])

And it's also possible to do the same for Index with tuples:

>>> pd.Index([('a', 'b'), ('b', 'c'), ('c', 'a')]) == ('c', 'a')
array([False, False, True])

But seems not working this way anymore after #34081 , is this length check here correct (so it is designed this way on purpose)? or we should consider it a bug?

cc @jbrockmendel

currently master:

>>> pd.Index([('a', 'b'), ('b', 'c'), ('c', 'a')]) == ('c', 'a')
ValueError: ('Lengths must match', (3,), (2,), <class 'tuple'>)
@charlesdong1991 charlesdong1991 added Bug Needs Triage Issue that has not been reviewed by a pandas team member Index Related to the Index class or subclasses and removed Needs Triage Issue that has not been reviewed by a pandas team member labels May 11, 2020
@jbrockmendel
Copy link
Member

Hmm good point. May be best to just revert #34081.

@jbrockmendel
Copy link
Member

or could treat tuples different from other listlikes

@charlesdong1991
Copy link
Member Author

take

@jorisvandenbossche
Copy link
Member

It's not just tuples, it's also any other "scalar" object that might have a length (eg dicts when storing those, but for example also Shapely geometries).
I seem to remember we have had this conversation before .. (don't directly remember the exact issue though)

I would maybe start with reverting, and can then try to think of a better solution.

@jorisvandenbossche
Copy link
Member

It seems @jbrockmendel actually recorded those concerns in an issue before: #27911

@charlesdong1991
Copy link
Member Author

emm, okay, i haven't looked at the changes in detail, sounds impact quite many cases. maybe let's revert it first then. thanks for the input @jorisvandenbossche

@jorisvandenbossche jorisvandenbossche added the Blocker Blocking issue or pull request for an upcoming release label May 12, 2020
@jorisvandenbossche jorisvandenbossche added this to the 1.1 milestone May 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Blocker Blocking issue or pull request for an upcoming release Bug Index Related to the Index class or subclasses
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants