-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
Feature Sugesstion: date_range from end to start #12355
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
Comments
reversed? In [7]: d=pd.date_range(start='2000', freq='Q', end='2002')
In [8]: d
Out[8]:
DatetimeIndex(['2000-03-31', '2000-06-30', '2000-09-30', '2000-12-31',
'2001-03-31', '2001-06-30', '2001-09-30', '2001-12-31'],
dtype='datetime64[ns]', freq='Q-DEC')
In [9]: reversed(d)
Out[9]: <reversed at 0x1073aaa20>
In [10]: pd.Index(reversed(d))
Out[10]:
DatetimeIndex(['2001-12-31', '2001-09-30', '2001-06-30', '2001-03-31',
'2000-12-31', '2000-09-30', '2000-06-30', '2000-03-31'],
dtype='datetime64[ns]', freq=None) |
Not reversed, the order doesn't change, but you work the algorithm from the end date to the start. I'll add an example above to make it more clear. |
so pls provide a usecase. Generally you would simply reverse sort to work with things in the reverse order. |
Here's a usecase: Say you do
You get
Which means my specified end_date is not a value in my list. With this flag, or "reverse generation" I would expect to get this instead:
(Note the month values) |
When using
pd.date_range
we work our way forwards from start to end. It would be nice to pass a flag or use the dates in reverse to go from end to start when creating the date_range.The text was updated successfully, but these errors were encountered: