

def _validate_for_numeric_binop(self, other, op, opstr):
    '\n        return valid other, evaluate or raise TypeError\n        if we are not of the appropriate type\n\n        internal method called by ops\n        '
    from pandas.tseries.offsets import DateOffset
    if (not self._is_numeric_dtype):
        raise TypeError('cannot evaluate a numeric op {opstr} for type: {typ}'.format(opstr=opstr, typ=type(self)))
    if isinstance(other, Index):
        if (not other._is_numeric_dtype):
            raise TypeError('cannot evaluate a numeric op {opstr} with type: {typ}'.format(opstr=type(self), typ=type(other)))
    elif (isinstance(other, np.ndarray) and (not other.ndim)):
        other = other.item()
    if isinstance(other, (Index, ABCSeries, np.ndarray)):
        if (len(self) != len(other)):
            raise ValueError('cannot evaluate a numeric op with unequal lengths')
        other = _values_from_object(other)
        if (other.dtype.kind not in ['f', 'i']):
            raise TypeError('cannot evaluate a numeric op with a non-numeric dtype')
    elif isinstance(op, (DateOffset, np.timedelta64, Timedelta, datetime.timedelta)):
        pass
    elif isinstance(other, (Timestamp, np.datetime64)):
        pass
    elif (not (is_float(other) or is_integer(other))):
        raise TypeError('can only perform ops with scalar values')
    return other

dataset/ETHPy150Open pydata/pandas/pandas/indexes/base.py Index._validate_for_numeric_binop/VarMisuse@209/382 `other`->`op`