@@ -150,9 +150,6 @@ class DatetimeIndex(Int64Index):
150
150
__le__ = _dt_index_cmp ('__le__' )
151
151
__ge__ = _dt_index_cmp ('__ge__' )
152
152
153
- __add__ = _dt_index_op ('__add__' )
154
- __sub__ = _dt_index_op ('__sub__' )
155
-
156
153
# structured array cache for datetime fields
157
154
_sarr_cache = None
158
155
@@ -420,7 +417,16 @@ def __add__(self, other):
420
417
return self .union (other )
421
418
elif isinstance (other , (datetools .DateOffset , timedelta )):
422
419
new_values = self .astype ('O' ) + other
423
- return DatetimeIndex (new_values , tz = self .tz )
420
+ return DatetimeIndex (new_values , tz = self .tz , freq = self .freq )
421
+ else :
422
+ return Index (self .view (np .ndarray ) + other )
423
+
424
+ def __sub__ (self , other ):
425
+ if isinstance (other , Index ):
426
+ return self .diff (other )
427
+ elif isinstance (other , (datetools .DateOffset , timedelta )):
428
+ new_values = self .astype ('O' ) - other
429
+ return DatetimeIndex (new_values , tz = self .tz , freq = self .freq )
424
430
else :
425
431
return Index (self .view (np .ndarray ) + other )
426
432
0 commit comments