parameters: (self, other)
return_statement: return new_values.view("timedelta64[ns]")
docstring: subtract DatetimeArray/Index or ndarray[datetime64]
docstring_summary: subtract DatetimeArray/Index or ndarray[datetime64]
docstring_tokens: subtract DatetimeArray / Index or ndarray [ datetime64 ]
function: def _sub_datetime_arraylike(self, other):
          """subtract DatetimeArray/Index or ndarray[datetime64]"""
          if len(self) != len(other):
              raise ValueError("cannot add indices of unequal length")
  
          if isinstance(other, np.ndarray):
              assert is_datetime64_dtype(other)
              other = type(self)(other)
  
          if not self._has_same_tz(other):
              # require tz compat
              raise TypeError(
                  f"{type(self).__name__} subtraction must have the same "
                  "timezones or no timezones"
              )
  
          self_i8 = self.asi8
          other_i8 = other.asi8
          arr_mask = self._isnan | other._isnan
          new_values = checked_add_with_arr(self_i8, -other_i8, arr_mask=arr_mask)
          if self._hasnans or other._hasnans:
              new_values[arr_mask] = iNaT
          return new_values.view("timedelta64[ns]")
function_tokens: def _sub_datetime_arraylike ( self , other ) : if len ( self ) != len ( other ) : raise ValueError ( "cannot add indices of unequal length" ) if isinstance ( other , np . ndarray ) : assert is_datetime64_dtype ( other ) other = type ( self ) ( other ) if not self . _has_same_tz ( other ) : # require tz compat raise TypeError ( f"{type(self).__name__} subtraction must have the same " "timezones or no timezones" ) self_i8 = self . asi8 other_i8 = other . asi8 arr_mask = self . _isnan | other . _isnan new_values = checked_add_with_arr ( self_i8 , - other_i8 , arr_mask = arr_mask ) if self . _hasnans or other . _hasnans : new_values [ arr_mask ] = iNaT return new_values . view ( "timedelta64[ns]" )