Skip to content

BUG: make resample with Day freq consistent with equivalent Hour freq - #64793

Merged
jbrockmendel merged 8 commits into
pandas-dev:mainfrom
jbrockmendel:big-resample-168
Jul 17, 2026
Merged

jbrockmendel merged 8 commits into
pandas-dev:mainfrom
jbrockmendel:big-resample-168

Conversation

@jbrockmendel

@jbrockmendel jbrockmendel commented Mar 23, 2026 •

Copy link
Copy Markdown
Member

closes #44996
closes #62200

On a timezone-naive index, resampling with a Day frequency (e.g. "7D") now produces the same bins as the equivalent Hour frequency ("168h"): origin and offset take effect instead of being silently ignored, and closed="right" no longer produces an extra trailing bin (GH-62200).

Timezone-aware indexes are intentionally unchanged: a calendar Day is not always 24 hours across DST transitions, so they keep calendar-day semantics and the existing RuntimeWarning that origin/offset do not take effect. (GH-44996 also reports the discrepancy for tz-aware indexes; that part is out of scope here.) The warning is now determined from the actual binning axis, so it fires correctly for pd.Grouper, on=, and groupby().resample() as well, and is no longer raised for offset on a TimedeltaIndex, where offset does take effect.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@jbrockmendel jbrockmendel added the Resample resample method label May 28, 2026
jbrockmendel and others added 4 commits June 11, 2026 14:48
The warning gate previously read obj.index.tz in TimeGrouper.__init__,
which is wrong when obj is None (pd.Grouper, groupby().resample()),
when resampling on a column, and for PeriodIndex/TimedeltaIndex. Move
the Day check to _get_resampler where the binning axis is resolved.
Also remove an unreachable re-localize block, skip the offset warning
on TimedeltaIndex where offset does take effect, and update the stale
resample docstring note (GH#44996).

Co-Authored-By: Claude Fable 5 <[email protected]>
# Conflicts:
#	doc/source/whatsnew/v3.1.0.rst
#	pandas/tests/resample/test_datetime_index.py
GH#43198 and GH#43896 regression tests asserted the old Day bin layout;
with tz-naive Day now matching the equivalent Hour freq, update their
expected bins accordingly.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@jbrockmendel
jbrockmendel marked this pull request as ready for review July 17, 2026 22:06
@jbrockmendel
jbrockmendel merged commit 5441d6a into pandas-dev:main Jul 17, 2026
49 checks passed
@jbrockmendel
jbrockmendel deleted the big-resample-168 branch July 17, 2026 23:47
Sharl0tteIsTaken added a commit to Sharl0tteIsTaken/pandas that referenced this pull request Jul 19, 2026
…-comparison

* upstream/main: (242 commits)
  PERF: vectorize to_datetime(DataFrame) field assembly (pandas-dev#65195)
  BUG: make resample with Day freq consistent with equivalent Hour freq (pandas-dev#64793)
  PERF: avoid redundant Index.equals calls in pd.concat (pandas-dev#66355)
  BUG: Fix TimedeltaIndex string slice resolution (pandas-dev#64870)
  BUG: rolling cov/corr NaN poisoning after empty window (GH#65739) (pandas-dev#66243)
  PERF: speed up nanops pearson correlation (pandas-dev#65502)
  BUG: PeriodIndex resample to a finer frequency bypassed aggregation (pandas-dev#65096)
  PERF: serialize tz-aware datetime to_json from datetime64 ndarray (pandas-dev#66007)
  PERF: faster to_datetime parsing of timezone-aware strings (pandas-dev#66123)
  BUG: read_csv parallel path silently corrupts data under low_memory=False (GH#64347) (pandas-dev#66327)
  BUG: Fix to_period losing month anchor for start/business offsets (pandas-dev#64954)
  BUG: DataFrame.agg with list of funcs mishandles non-reduction methods (GH#65031) (pandas-dev#66173)
  BUG: nullable/arrow EA setitem silently storing out-of-range values (GH#47776) (pandas-dev#66321)
  DEPR: to_datetime with integer/float values and format argument (pandas-dev#65181)
  BUG: setitem-with-expansion casting regressions from GH#62523 (pandas-dev#66251)
  BUG: SparseArray.astype to int silently dropped NaT fill via Series.astype (GH#49631) (pandas-dev#66175)
  BUG: loc/iloc split-path 2D setitem with a list of 1-D arrays silently transposed (GH#64230) (pandas-dev#66244)
  BUG: unstack CoW-aliasing untracked for tz-aware/period columns (GH#65748) (pandas-dev#66163)
  BUG: groupby quantile with non-null NaN and all-NaT groups (GH#64330) (pandas-dev#66183)
  BUG: tz_localize/tz_convert wrong for non-nanosecond resolution before 1677 (pandas-dev#66252)
  ...
spencerkclark added a commit to pydata/xarray that referenced this pull request Aug 30, 2026
### Description

Pandas is rolling back a change we adapted to about a year ago (#10650) related to resampling with a `Day` frequency (pandas-dev/pandas#64793).  This PR makes the necessary changes in xarray to do the same.

This addresses some of the upstream failures surfaced in #11501.

### Checklist

- [x] Tests added
- [x] User visible changes (including notable bug fixes) are documented in `whats-new.rst`

### AI Disclosure

This PR was created without AI.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Resample resample method

Projects

None yet

1 participant