Skip to content

TST: tz-aware grouper/map returning tz-naive (GH#57192)#65997

Merged
jbrockmendel merged 1 commit into
pandas-dev:mainfrom
jbrockmendel:bug-57192
Jun 26, 2026
Merged

TST: tz-aware grouper/map returning tz-naive (GH#57192)#65997
jbrockmendel merged 1 commit into
pandas-dev:mainfrom
jbrockmendel:bug-57192

Conversation

@jbrockmendel

Copy link
Copy Markdown
Member

closes #57192

Grouping a tz-aware DatetimeIndex by a function that strips the tz (e.g. ts.normalize().tz_convert(None)) used to give back group keys re-localized to the original tz instead of the tz-naive values the function returned. Same for DatetimeIndex.map.

This was a regression introduced by EA._from_scalars (GH-53089) and already fixed by the EA._cast_pointwise_result refactor (GH-62105), which no longer routes the NDArrayBacked map path through _from_scalars. Adding regression tests at both the map (root cause) and groupby (reported) levels.

Add regression tests covering DatetimeIndex.map and groupby with a
function that strips the tz; the result should be tz-naive rather than
re-localized to the original tz.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jbrockmendel jbrockmendel added Testing pandas testing functions or related to the test suite Groupby Timezones Timezone data dtype labels Jun 23, 2026
@jbrockmendel jbrockmendel marked this pull request as ready for review June 26, 2026 16:29
@jbrockmendel jbrockmendel merged commit ea93ae9 into pandas-dev:main Jun 26, 2026
51 of 53 checks passed
@jbrockmendel jbrockmendel deleted the bug-57192 branch June 26, 2026 16:29
@rhshadrach rhshadrach added this to the 3.1 milestone Jun 26, 2026
hamdanal pushed a commit to hamdanal/pandas that referenced this pull request Jun 27, 2026
…5997)

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Groupby Testing pandas testing functions or related to the test suite Timezones Timezone data dtype

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: pandas 2.2.0 DataFrame.groupby regression when group labels of type pd.Timestamp

2 participants