Skip to content

BUG: setting tuple key on Series with flat Index #55141

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

Open
3 tasks done
jbrockmendel opened this issue Sep 14, 2023 · 0 comments
Open
3 tasks done

BUG: setting tuple key on Series with flat Index #55141

jbrockmendel opened this issue Sep 14, 2023 · 0 comments
Labels
Bug Indexing Related to indexing on series/frames, not to indexes themselves Series Series data structure

Comments

@jbrockmendel
Copy link
Member

Pandas version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

dti = pd.date_range('2016-01-01', periods=3)
idx = Index(range(3))

ser = pd.Series(range(3), index=dti)
ser2 = pd.Series(range(3), index=idx)

key = (1, 2)
value = 9

ser[key] = value  # <- raises KeyError: 'key of type tuple not found and not a MultiIndex'
ser2[key] = value # <- raises pandas.errors.IndexingError: Too many indexers

Issue Description

In this example the user wants to treat (1,2) as a scalar label but doing so fails. I'd be open to "the user shouldn't do this". Otherwise I think something like #42349 to make users be explicit when they want to do something ugly like this is probably simpler than us trying to do inference on maybe-labels.

Expected Behavior

NA

Installed Versions

Replace this line with the output of pd.show_versions()

@jbrockmendel jbrockmendel added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Sep 14, 2023
@lithomas1 lithomas1 added Indexing Related to indexing on series/frames, not to indexes themselves Series Series data structure and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Jan 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Indexing Related to indexing on series/frames, not to indexes themselves Series Series data structure
Projects
None yet
Development

No branches or pull requests

2 participants