DateOffsets should allow element-wise addition to Series #10699

Closed
jorisvandenbossche opened this Issue Jul 29, 2015 · 2 comments

Comments

Projects
None yet
3 participants

Adding a DateOffset works for single Timestamps and for DatetimeIndex, but fails on a Series:

In [132]: s = pd.Series(pd.date_range('2012-01-01', periods=3))

In [133]: s
Out[133]:
0   2012-01-01
1   2012-01-02
2   2012-01-03
dtype: datetime64[ns]

In [134]: s[0] + pd.DateOffset(months=2)
Out[134]: Timestamp('2012-03-01 00:00:00')

In [135]: pd.DatetimeIndex(s) + pd.DateOffset(months=2)
Out[135]: DatetimeIndex(['2012-03-01', '2012-03-02', '2012-03-03'], dtype='datetime64[ns]', freq='D', tz=None)

In [136]: s + pd.DateOffset(months=2)
---------------------------------------------------------------------------
TypeError: cannot use a non-absolute DateOffset in datetime/timedelta operations
 [<DateOffset: kwds={'months': 2}>]
Member

sinhrks commented Jul 30, 2015

+1. Also it's nice if other offset methods like onOffset can accept list-likes.

jreback added this to the 0.17.0 milestone Aug 6, 2015

Contributor

jreback commented Aug 13, 2015

closed by #10744

jreback closed this Aug 13, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment