Skip to content

BUG: fix date_range inclusive filtering with periods#64788

Merged
mroeschke merged 1 commit intopandas-dev:mainfrom
jbrockmendel:bug-46331
Mar 25, 2026
Merged

BUG: fix date_range inclusive filtering with periods#64788
mroeschke merged 1 commit intopandas-dev:mainfrom
jbrockmendel:bug-46331

Conversation

@jbrockmendel
Copy link
Copy Markdown
Member

Summary

  • fixes date_range ignoring the inclusive parameter when called with start+periods or end+periods (without the other endpoint)
  • When end (or start) was None, Timestamp(None) produced NaT, so the endpoint comparison always failed and the boundary value was never filtered out
  • Fixes by defaulting to the actual array endpoints when start/end is None

closes #46331

Test plan

  • Added parametrized tests for start+periods and end+periods across all four inclusive values (both, left, right, neither)
  • All existing date_range tests continue to pass

🤖 Generated with Claude Code

@jbrockmendel jbrockmendel force-pushed the bug-46331 branch 3 times, most recently from 17919cf to b9b57db Compare March 25, 2026 17:14
@jbrockmendel jbrockmendel marked this pull request as ready for review March 25, 2026 17:15
When date_range was called with start+periods or end+periods (without
the other endpoint), the inclusive parameter failed to filter the
unspecified endpoint because Timestamp(None) produced NaT, causing the
endpoint comparison to always fail.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@mroeschke mroeschke added this to the 3.1 milestone Mar 25, 2026
@mroeschke mroeschke merged commit 40c3159 into pandas-dev:main Mar 25, 2026
45 checks passed
@mroeschke
Copy link
Copy Markdown
Member

Thanks @jbrockmendel

@jbrockmendel jbrockmendel deleted the bug-46331 branch March 25, 2026 21:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: the behavior of "date_range" function with "periods & inclusive" arguments

2 participants