예제 #1
0
 def _convert_tolerance(self, tolerance, target):
     tolerance = DatetimeIndexOpsMixin._convert_tolerance(self, tolerance,
                                                          target)
     if target.size != tolerance.size and tolerance.size > 1:
         raise ValueError('list-like tolerance size must match '
                          'target index size')
     return self._maybe_convert_timedelta(tolerance)
예제 #2
0
 def _convert_tolerance(self, tolerance, target):
     tolerance = DatetimeIndexOpsMixin._convert_tolerance(
         self, tolerance, target)
     if target.size != tolerance.size and tolerance.size > 1:
         raise ValueError('list-like tolerance size must match '
                          'target index size')
     return self._maybe_convert_timedelta(tolerance)
예제 #3
0
파일: timedeltas.py 프로젝트: v-node/pandas
 def _addsub_offset_array(self, other, op):
     # Add or subtract Array-like of DateOffset objects
     try:
         # TimedeltaIndex can only operate with a subset of DateOffset
         # subclasses.  Incompatible classes will raise AttributeError,
         # which we re-raise as TypeError
         return DatetimeIndexOpsMixin._addsub_offset_array(self, other, op)
     except AttributeError:
         raise TypeError("Cannot add/subtract non-tick DateOffset to {cls}"
                         .format(cls=type(self).__name__))
예제 #4
0
 def astype(self, dtype, copy=True):
     dtype = pandas_dtype(dtype)
     if is_timedelta64_dtype(dtype) and not is_timedelta64_ns_dtype(dtype):
         # Have to repeat the check for 'timedelta64' (not ns) dtype
         #  so that we can return a numeric index, since pandas will return
         #  a TimedeltaIndex when dtype='timedelta'
         result = self._data.astype(dtype, copy=copy)
         if self.hasnans:
             return Index(result, name=self.name)
         return Index(result.astype("i8"), name=self.name)
     return DatetimeIndexOpsMixin.astype(self, dtype, copy=copy)
예제 #5
0
파일: timedeltas.py 프로젝트: Itay4/pandas
 def astype(self, dtype, copy=True):
     dtype = pandas_dtype(dtype)
     if is_timedelta64_dtype(dtype) and not is_timedelta64_ns_dtype(dtype):
         # Have to repeat the check for 'timedelta64' (not ns) dtype
         #  so that we can return a numeric index, since pandas will return
         #  a TimedeltaIndex when dtype='timedelta'
         result = self._data.astype(dtype, copy=copy)
         if self.hasnans:
             return Index(result, name=self.name)
         return Index(result.astype('i8'), name=self.name)
     return DatetimeIndexOpsMixin.astype(self, dtype, copy=copy)
예제 #6
0
    def insert(self, loc: int, item):
        if not isinstance(item, Period) or self.freq != item.freq:
            return self.astype(object).insert(loc, item)

        return DatetimeIndexOpsMixin.insert(self, loc, item)
예제 #7
0
파일: timedeltas.py 프로젝트: Itay4/pandas
 def _join_i8_wrapper(joinf, **kwargs):
     return DatetimeIndexOpsMixin._join_i8_wrapper(
         joinf, dtype='m8[ns]', **kwargs)
예제 #8
0
파일: timedeltas.py 프로젝트: vesh/pandas
 def _join_i8_wrapper(joinf, **kwargs):
     return DatetimeIndexOpsMixin._join_i8_wrapper(joinf,
                                                   dtype='m8[ns]',
                                                   **kwargs)
예제 #9
0
 def _convert_tolerance(self, tolerance):
     tolerance = DatetimeIndexOpsMixin._convert_tolerance(self, tolerance)
     return self._maybe_convert_timedelta(tolerance)
예제 #10
0
 def _convert_tolerance(self, tolerance):
     tolerance = DatetimeIndexOpsMixin._convert_tolerance(self, tolerance)
     return self._maybe_convert_timedelta(tolerance)