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] Scalar loc-based lookup in integer categorical indices is incorrect #13653

Open
Tracked by #12793
wence- opened this issue Jul 3, 2023 · 0 comments · May be fixed by #13717
Open
Tracked by #12793

[BUG] Scalar loc-based lookup in integer categorical indices is incorrect #13653

wence- opened this issue Jul 3, 2023 · 0 comments · May be fixed by #13717
Assignees
Labels
2 - In Progress Currently a work in progress bug Something isn't working Python Affects Python cuDF API.

Comments

@wence-
Copy link
Contributor

wence- commented Jul 3, 2023

Describe the bug

loc-based lookup does (I think incorrect) fallback to positional indexing rather than label-based lookup when the index is a categorical one with integer values.

Steps/Code to reproduce bug

import cudf

s = cudf.Series([1, 2], index=cudf.CategoricalIndex([3, 4], categories=[3, 4]))
s.loc[3] # IndexError: single positional indexer is out-of-bounds

Expected behavior

s.to_pandas().loc[3]
# 1

Annoyingly, one can't just stop doing positional indexing fallback in all cases because if the index is (say) a string index then integer indexing does fall back to positional. This is for Series.__getitem__ and the behaviour is deprecated in pandas 2.

@wence- wence- added bug Something isn't working 0 - Backlog In queue waiting for assignment Python Affects Python cuDF API. labels Jul 3, 2023
@wence- wence- self-assigned this Jul 3, 2023
@wence- wence- changed the title [BUG] Scalar loc-based lookup of in integer categorical indices is incorrect [BUG] Scalar loc-based lookup in integer categorical indices is incorrect Jul 3, 2023
@wence- wence- added 2 - In Progress Currently a work in progress and removed 0 - Backlog In queue waiting for assignment labels Jul 5, 2023
@wence- wence- linked a pull request Jul 18, 2023 that will close this issue
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2 - In Progress Currently a work in progress bug Something isn't working Python Affects Python cuDF API.
Projects
Status: No status
Development

Successfully merging a pull request may close this issue.

1 participant