-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
be more careful with half-opened date_range #11806
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
need some tests for this. pls use all of the examples that you provided on gitter. |
@@ -487,10 +487,9 @@ def _generate(cls, start, end, periods, name, offset, | |||
index = index.view(_NS_DTYPE) | |||
|
|||
index = cls._simple_new(index, name=name, freq=offset, tz=tz) | |||
|
|||
if not left_closed: | |||
if not left_closed and (start is not None and index[0] == start): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if not left_closed and len(index) and index[0] == start
941f7fd
to
a3125c6
Compare
closed_right = date_range('2015-09-12', '2015-12-01', freq='QS-MAR', closed='right') | ||
closed_left = date_range('2015-09-01', '2015-10-30', freq='QS-MAR', closed='left') | ||
expected_left = DatetimeIndex(['2015-09-01']) | ||
expected_right = DatetimeIndex(['2015-12-01']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also add in closed=None
.
Further do this test for start/end on the boundaries & not on the boundaries.
I think you should have 9 possibilities here (3 from closed parm, 3 from if start/end on boundary)
lgtm. can you add a whatsnew note (bug fixes), and squash. ping when green. |
a32b141
to
5acb37a
Compare
5acb37a
to
1a51b41
Compare
@jreback done. I wasn't sure if there is a specific order for the whatsnew notes, let me know if I didn't do it right. Thanks. |
be more careful with half-opened date_range
@thrasibule thanks! no specific order in whatsnew, best to put it in the middle somewhere as that tends to not cause merge conflicts (and the reason I leave space for it) |
Thanks for merging! |
closes #11804
This changes the definition of 'left' and 'right'. If the generated_dates are strictly within (start, end), then changing the value of closed has no impact. Before the code would always remove the leftmost date or rightmost date independently of the value of start and end.