Skip to content

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

Merged
merged 1 commit into from
Dec 17, 2015

Conversation

thrasibule
Copy link
Contributor

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.

@jreback jreback added Bug Datetime Datetime data dtype Frequency DateOffsets labels Dec 10, 2015
@jreback jreback added this to the 0.18.0 milestone Dec 10, 2015
@jreback
Copy link
Contributor

jreback commented Dec 10, 2015

need some tests for this. pls use all of the examples that you provided on gitter.

@jreback jreback removed this from the 0.18.0 milestone Dec 10, 2015
@@ -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):
Copy link
Contributor

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

@thrasibule thrasibule force-pushed the daterange_fix branch 3 times, most recently from 941f7fd to a3125c6 Compare December 10, 2015 22:48
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'])
Copy link
Contributor

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)

@jreback
Copy link
Contributor

jreback commented Dec 17, 2015

lgtm. can you add a whatsnew note (bug fixes), and squash. ping when green.

@jreback jreback added this to the 0.18.0 milestone Dec 17, 2015
@thrasibule
Copy link
Contributor Author

@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.

jreback added a commit that referenced this pull request Dec 17, 2015
be more careful with half-opened date_range
@jreback jreback merged commit 71f652d into pandas-dev:master Dec 17, 2015
@jreback
Copy link
Contributor

jreback commented Dec 17, 2015

@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)

@thrasibule thrasibule deleted the daterange_fix branch December 18, 2015 19:31
@thrasibule
Copy link
Contributor Author

Thanks for merging!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Datetime Datetime data dtype Frequency DateOffsets
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DatetimeIndex with closed='left' or 'right' drop dates at the boundaries
2 participants