BUG: np.timedelta64 arithmetic appears buggy · Issue #4135 · pandas-dev/pandas (original) (raw)

Buggy timedelta arithmetic with np.timedelta64 in np 1.7.1

In [41]: s = Series([Timestamp('20130301'),Timestamp('20130228 23:00:00'),Timestamp('20130228 22:00:00'),Timestamp('20130228 21:00:00')])

In [42]: s
Out[42]: 
0   2013-03-01 00:00:00
1   2013-02-28 23:00:00
2   2013-02-28 22:00:00
3   2013-02-28 21:00:00
dtype: datetime64[ns]

In [43]: s + timedelta(hours=1)
Out[43]: 
0   2013-03-01 01:00:00
1   2013-03-01 00:00:00
2   2013-02-28 23:00:00
3   2013-02-28 22:00:00
dtype: datetime64[ns]

Should be the same as above

In [45]: s + np.timedelta64(1,'h')
Out[45]: 
0   2013-03-01 00:00:00.000000001
1   2013-02-28 23:00:00.000000001
2   2013-02-28 22:00:00.000000001
3   2013-02-28 21:00:00.000000001
dtype: datetime64[ns]