Skip to content

BUG: fix extra trailing bin in resample("D", closed="right")#64795

Draft
jbrockmendel wants to merge 1 commit intopandas-dev:mainfrom
jbrockmendel:bug-resample-right
Draft

BUG: fix extra trailing bin in resample("D", closed="right")#64795
jbrockmendel wants to merge 1 commit intopandas-dev:mainfrom
jbrockmendel:bug-resample-right

Conversation

@jbrockmendel
Copy link
Member

Summary

  • Fixes the regression where resample("D", closed="right") produced an extra trailing empty bin compared to resample("24h", closed="right") when the last value falls on a Day boundary (midnight).
  • When Day was changed from a Tick subclass, the non-Tick path in _get_timestamp_range_edges unconditionally extended last by one freq. Now it skips the extension when closed="right", freq is Day, and last is already at midnight.

closes #62200

Test plan

  • Added test_resample_D_closed_right_no_extra_bin — verifies D and 24h produce the same result with closed="right"
  • Added test_resample_D_closed_right_label_right_no_extra_bin — original reproducer from the issue
  • Added test_resample_D_closed_right_not_on_boundary — ensures trailing bin is still present when last value is not at midnight
  • Full resample test suite passes (4102 passed)

🤖 Generated with Claude Code

…dev#62200) When Day was changed from a Tick subclass, the non-Tick path in _get_timestamp_range_edges unconditionally extended last by one freq, creating a spurious empty bin when closed="right" and last was already on a Day boundary. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1 participant