BUG: bdate_range(end, periods, freq=nB) anchors stride at buffer start#65604
Draft
jbrockmendel wants to merge 2 commits into
Draft
BUG: bdate_range(end, periods, freq=nB) anchors stride at buffer start#65604jbrockmendel wants to merge 2 commits into
jbrockmendel wants to merge 2 commits into
Conversation
…buffer Follow-up to pandas-devGH-64648: when end + periods are given and freq is n*B (or n*C) with n >= 2, the [::abs_n] stride was anchored at the start of the internal buffer instead of at end, producing dates offset by (buffer_days % n). Reverse before striding so the anchor is the last on-offset date <= end. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Member
|
Thanks, looks good to me |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to GH-64648, addressing a regression flagged by @jorisvandenbossche in post-merge review.
When
bdate_range/date_rangeis called withend+periodsandfreq="nB"(or"nC") wheren >= 2, the new fast path ingenerate_daily_offset_rangeanchored the[::n]stride at the start of the internal buffer instead of atend. The result was offset bybuffer_days % n:n=1was unaffected. Onlyn>=2withend+periodsis broken.The fix reverses the array before striding so the anchor is the last on-offset date
<= end, then reverses back. Symmetric with the existingtrim_from_endbranch a few lines later.This regression only exists on main — 3.0.x doesn't have GH-64648 and uses the old
_generate_rangepath, which handlesnBcorrectly. No 3.1.0 has been released yet, so no whatsnew entry.Test plan
endon Fri/Sat/Sun withfreq="2B"and"3B"pandas/tests/indexes/datetimes/test_date_range.py(421 tests) passespandas/tests/tseries/(6941 tests) passes🤖 Generated with Claude Code