-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Feature request: Add annual offset that is not anchored #15685
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
There could be a better API, or at minimum better docs, but you can accomplish this with a In [216]: pd.date_range(end='2017-03-12', periods=12, freq=pd.DateOffset(years=1))
Out[216]:
DatetimeIndex(['2006-03-12', '2007-03-12', '2008-03-12', '2009-03-12',
'2010-03-12', '2011-03-12', '2012-03-12', '2013-03-12',
'2014-03-12', '2015-03-12', '2016-03-12', '2017-03-12'],
dtype='datetime64[ns]', freq='<DateOffset: kwds={'years': 1}>') |
@chris-b1 |
Oh, one to to note is that Getting hackier, but I think this would work? pd.date_range(end='2017-03-12', periods=12, freq=pd.DateOffset(years=1)) + pd.offsets.BusinessDay(n=0)
Out[225]:
DatetimeIndex(['2006-03-13', '2007-03-12', '2008-03-12', '2009-03-12',
'2010-03-12', '2011-03-14', '2012-03-12', '2013-03-12',
'2014-03-12', '2015-03-12', '2016-03-14', '2017-03-13'],
dtype='datetime64[ns]', freq=None) |
@chris-b1 When using either |
Code Sample, a copy-pastable example if possible
Problem description
Pandas
divides offsets intoregular
andanchored
(see Offset aliases).There are
regular
aliases for any frequency but annual. A typical use case - give me abdate_range
with dates spaced 1 year apart ending today.12M
and52W
are only proxies, but won't give the exact expected result.Expected Output
Output of
pd.show_versions()
The text was updated successfully, but these errors were encountered: