|
13 | 13 | is_integer, is_float,
|
14 | 14 | is_bool_dtype, _ensure_int64,
|
15 | 15 | is_scalar, is_dtype_equal,
|
| 16 | + is_timedelta64_dtype, is_integer_dtype, |
16 | 17 | is_list_like)
|
17 | 18 | from pandas.core.dtypes.generic import (
|
18 | 19 | ABCIndex, ABCSeries,
|
@@ -651,6 +652,15 @@ def __add__(self, other):
|
651 | 652 | raise TypeError("cannot add {typ1} and {typ2}"
|
652 | 653 | .format(typ1=type(self).__name__,
|
653 | 654 | typ2=type(other).__name__))
|
| 655 | + elif isinstance(other, np.ndarray): |
| 656 | + if is_timedelta64_dtype(other): |
| 657 | + return self._add_delta(TimedeltaIndex(other)) |
| 658 | + elif is_integer_dtype(other): |
| 659 | + return NotImplemented |
| 660 | + else: |
| 661 | + raise TypeError("cannot add {typ1} and np.ndarray[{typ2}]" |
| 662 | + .format(typ1=type(self).__name__, |
| 663 | + typ2=other.dtype)) |
654 | 664 | elif isinstance(other, (DateOffset, timedelta, np.timedelta64,
|
655 | 665 | Timedelta)):
|
656 | 666 | return self._add_delta(other)
|
@@ -731,7 +741,7 @@ def _add_delta_tdi(self, other):
|
731 | 741 | if self.hasnans or other.hasnans:
|
732 | 742 | mask = (self._isnan) | (other._isnan)
|
733 | 743 | new_values[mask] = iNaT
|
734 |
| - return new_values.view(self.dtype) |
| 744 | + return new_values.view('i8') |
735 | 745 |
|
736 | 746 | def isin(self, values):
|
737 | 747 | """
|
|
0 commit comments