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] Incorrect name selection in Index.difference when an object with no-name is passed #14019

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

Comments

@galipremsagar
Copy link
Contributor

Describe the bug
When a difference is calculated with an object that has no name, the result should have the name of the Index object itself.

Steps/Code to reproduce bug

In [1]: import cudf

In [2]: s = cudf.Index(['a', 'b', 'c'], name="abc")

In [3]: s.difference([])
Out[3]: StringIndex(['a' 'b' 'c'], dtype='object')

In [4]: s.to_pandas().difference([])
Out[4]: Index(['a', 'b', 'c'], dtype='object', name='abc')

Expected behavior

In [4]: s.difference([])
Out[4]: Index(['a', 'b', 'c'], dtype='object', name='abc')

Environment overview (please complete the following information)

  • Environment location: [Bare-metal]
  • Method of cuDF install: [from source]
@galipremsagar galipremsagar added bug Something isn't working Python Affects Python cuDF API. labels Aug 31, 2023
@galipremsagar galipremsagar self-assigned this Aug 31, 2023
rapids-bot bot pushed a commit that referenced this issue Sep 8, 2023
This PR fixes `Index.difference` in following ways:

- [x] Fixes `name` preservation by correctly evaluating the name of two input objects, closes #14019
- [x] Fixes `is_mixed_with_object_dtype` handling that will resolve incorrect results for `CategoricalIndex`, closes #14022
- [x] Raises errors for invalid input types, the error messages are an exact match to pandas error messages for parity.
- [x] Introduce a `Range._try_reconstruct_range_index` that will try to re-construct a `RangeIndex` out of an `Int..Index` to save memory- this is on parity with pandas. closes #14013

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

Approvers:
  - Lawrence Mitchell (https://github.com/wence-)

URL: #14053
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.

1 participant