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

[BUG] MultiIndex.isin returns True instead of False for partial element matching tuples #13861

Closed
mroeschke opened this issue Aug 11, 2023 · 0 comments · Fixed by #13879
Closed
Assignees
Labels
bug Something isn't working Python Affects Python cuDF API.

Comments

@mroeschke
Copy link
Contributor

Describe the bug
MultiIndex.isin returns True for partial element matching tuples

Steps/Code to reproduce bug

In [41]: import cudf

In [42]: cudf.__version__
Out[42]: '23.10.00'

In [43]: mi = cudf.MultiIndex.from_product([[0, 1], ['a', 'b', 'c']])

In [44]: mi.isin([(1, 'a'), (2, 'b'), (0, 'c')])
Out[44]: array([ True,  True,  True,  True,  True,  True])

In [45]: mi
Out[45]: 
MultiIndex([(0, 'a'),
            (0, 'b'),
            (0, 'c'),
            (1, 'a'),
            (1, 'b'),
            (1, 'c')],
           )

Expected behavior
isin should only return True if all elements in a tuple a MultiIndex label

In [47]: mi = pandas.MultiIndex.from_product([[0, 1], ['a', 'b', 'c']])

In [48]: mi.isin([(1, 'a'), (2, 'b'), (0, 'c')])
Out[48]: array([False, False,  True,  True, False, False])

Environment overview (please complete the following information)

  • Environment location: Bare-metal
  • Method of cuDF install: conda
    • If method of install is [Docker], provide docker pull & docker run commands used

Environment details
Please run and paste the output of the cudf/print_env.sh script here, to gather any other relevant environment details

Additional context
Add any other context about the problem here.

@mroeschke mroeschke added bug Something isn't working Needs Triage Need team to review and classify labels Aug 11, 2023
@galipremsagar galipremsagar self-assigned this Aug 14, 2023
@galipremsagar galipremsagar added Python Affects Python cuDF API. and removed Needs Triage Need team to review and classify labels Aug 14, 2023
rapids-bot bot pushed a commit that referenced this issue Aug 14, 2023
Fixes: #13861 

This PR fixes an issue in `MulitIndex.isin` where, previously we calculated partial matches. With this PR we will only return `True` for complete matches.

Authors:
  - GALI PREM SAGAR (https://github.com/galipremsagar)

Approvers:
  - Bradley Dice (https://github.com/bdice)

URL: #13879
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Python Affects Python cuDF API.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants