Skip to content

ENH: Make use of RangeIndex in DatetimeIndex #12272

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

Closed
kawochen opened this issue Feb 9, 2016 · 5 comments
Closed

ENH: Make use of RangeIndex in DatetimeIndex #12272

kawochen opened this issue Feb 9, 2016 · 5 comments
Labels
Datetime Datetime data dtype Index Related to the Index class or subclasses Performance Memory or execution speed performance

Comments

@kawochen
Copy link
Contributor

kawochen commented Feb 9, 2016

DatetimeIndex looks like it can benefit from RangeIndex #11892 .
Use case 1: Evenly-spaced time-series analysis
Use case 2: I sometimes (ab)use date_range like a PY3 range in a for loop, which I think is quite neat. It would be cooler if it were lazily evaluated.

@jreback
Copy link
Contributor

jreback commented Feb 9, 2016

@kawochen absolutely for 1 (might not even be that tricky as would simply need to move to sub-class from Int64Index to RangeIndex

can you give a more full example for 2)?

@jreback jreback added Datetime Datetime data dtype Performance Memory or execution speed performance API Design labels Feb 9, 2016
@jreback jreback added this to the Next Major Release milestone Feb 9, 2016
@jreback jreback added the Needs Discussion Requires discussion from core team before further action label Feb 9, 2016
@kawochen
Copy link
Contributor Author

kawochen commented Feb 9, 2016

For 2) I just meant

for d in date_range('20110101', '20121225'):
    process(d)

It's much better than updating with some time delta, and quacks like datetime.datetime enough that it serves all needs I have for the latter.
It solves this SO problem perfectly.

@jreback
Copy link
Contributor

jreback commented Feb 9, 2016

ah I c.

that brings up a good point actually. __iter__ is NOT lazy ATM for Int64Index, but for RangeIndex it certainly could/should be.

@max-sixty
Copy link
Contributor

...and PeriodIndex!

@mroeschke mroeschke removed the Needs Discussion Requires discussion from core team before further action label Mar 31, 2020
@mroeschke mroeschke added Index Related to the Index class or subclasses and removed API Design labels Apr 23, 2021
@mroeschke mroeschke removed this from the Contributions Welcome milestone Oct 13, 2022
@mroeschke
Copy link
Member

Looks like this idea never took off, and since it's possible for DatetimeIndex to be non-monotonic may make the complexity onerous so closing for now. Can reopen if there's interest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Datetime Datetime data dtype Index Related to the Index class or subclasses Performance Memory or execution speed performance
Projects
None yet
Development

No branches or pull requests

4 participants