Skip to content

date_range should (at least optionally) deal with right-open intervals #4579

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 2 commits into from
Oct 15, 2013

Conversation

filmor
Copy link
Contributor

@filmor filmor commented Oct 3, 2013

It is confusing that, albeit the name suggests otherwise, date_range behaves differently compared to the standard Python range generator in that it returns the right-closed interval.

@jreback
Copy link
Contributor

jreback commented Sep 30, 2013

@filmor you can submit a PR if you would like, but this is essentially label based indexing, so the python convention doesn't apply here. That side, having a closed=left|right' would not be a bad option

@filmor
Copy link
Contributor Author

filmor commented Oct 3, 2013

I still have to build some test-cases for the new inputs before this is ready for merge.

@jreback
Copy link
Contributor

jreback commented Oct 3, 2013

I think closed can only apply to the right side (too confusing othewise). Also pls add a release notes and v0.13 entry (enhancements)

@filmor
Copy link
Contributor Author

filmor commented Oct 4, 2013

The current commit contains a release note, but I don't understand your comment on the parameter. What is wrong with being able to have open, left-open, right-open and closed intervals? There are uses for all of them and the interface seems pretty obvious to me …

@jreback
Copy link
Contributor

jreback commented Oct 4, 2013

take a look at tseries/resample.py/TimeGroup

closed=None is the default, can be 'right' or 'left'....let's go with this so the API is not changed

None is your equivalent of True, False (meaning both open) is not supported

can't change the API ATM different from what exists in the rest of pandas.
(you are welcome to do that in 0.14, but that would require some more discussion)

@jreback
Copy link
Contributor

jreback commented Oct 7, 2013

@filmor need some tests for this; e.g. with closed taking on each value and that the generated range is correct (for several freqs should be good). should go in tseries/tests/test_daterange.py

@filmor
Copy link
Contributor Author

filmor commented Oct 9, 2013

Could you have a look at the Travis output? An error occurs in a place, where I didn't change anything(tm), for some reason the Timestamps in DatetimeIndex._generate are converted back to datetime.datetime without a tz attribute, leading to an error. However this only seems to happen after the start += offset or end -= offset call ...

@jreback
Copy link
Contributor

jreback commented Oct 11, 2013

@filmor did you fix the bug?

@jreback
Copy link
Contributor

jreback commented Oct 14, 2013

@filmor how's this coming?

@jreback jreback merged commit d6dcbb4 into pandas-dev:master Oct 15, 2013
@jreback
Copy link
Contributor

jreback commented Oct 15, 2013

thanks for the PR!

@filmor filmor deleted the date_range branch October 16, 2013 07:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Datetime Datetime data dtype Enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants