Skip to content

DEPR: Treat tuple keys consistently in Resampler.__getitem__#66270

Open
EsDeath-Boop wants to merge 1 commit into
pandas-dev:mainfrom
EsDeath-Boop:depr-resample-tuple-getitem
Open

DEPR: Treat tuple keys consistently in Resampler.__getitem__#66270
EsDeath-Boop wants to merge 1 commit into
pandas-dev:mainfrom
EsDeath-Boop:depr-resample-tuple-getitem

Conversation

@EsDeath-Boop

Copy link
Copy Markdown

Closes #66266.

Summary

Resampler.__getitem__ currently treats tuple keys as a list of column
labels. For example,

df.resample("h")["A", "B"]

behaves like

df.resample("h")[["A", "B"]]

instead of following DataFrame.__getitem__ semantics.

This PR updates Resampler.__getitem__ so that tuple keys are forwarded
to the underlying DataFrame selection. As a result:

  • tuple keys correctly select MultiIndex columns
  • tuple keys on non-MultiIndex columns raise KeyError

Tests

  • Updated test_getitem to expect a KeyError for tuple keys on regular columns.
  • Added a regression test for tuple-key selection on MultiIndex columns.

@EsDeath-Boop EsDeath-Boop force-pushed the depr-resample-tuple-getitem branch from 71e7cdd to d9d35a0 Compare July 10, 2026 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DEPR: Using lists and tuples interchangeably in resample

1 participant