13
13
from pandas import compat
14
14
15
15
16
- from pandas .core .dtypes .generic import ABCSeries , ABCMultiIndex , ABCPeriodIndex
16
+ from pandas .core .dtypes .generic import (
17
+ ABCSeries ,
18
+ ABCMultiIndex ,
19
+ ABCPeriodIndex ,
20
+ ABCDateOffset )
17
21
from pandas .core .dtypes .missing import isna , array_equivalent
18
22
from pandas .core .dtypes .common import (
19
23
_ensure_int64 ,
@@ -3814,8 +3818,6 @@ def _validate_for_numeric_binop(self, other, op, opstr):
3814
3818
3815
3819
internal method called by ops
3816
3820
"""
3817
- from pandas .tseries .offsets import DateOffset
3818
-
3819
3821
# if we are an inheritor of numeric,
3820
3822
# but not actually numeric (e.g. DatetimeIndex/PeriodInde)
3821
3823
if not self ._is_numeric_dtype :
@@ -3843,7 +3845,7 @@ def _validate_for_numeric_binop(self, other, op, opstr):
3843
3845
if other .dtype .kind not in ['f' , 'i' , 'u' ]:
3844
3846
raise TypeError ("cannot evaluate a numeric op "
3845
3847
"with a non-numeric dtype" )
3846
- elif isinstance (other , (DateOffset , np .timedelta64 ,
3848
+ elif isinstance (other , (ABCDateOffset , np .timedelta64 ,
3847
3849
Timedelta , datetime .timedelta )):
3848
3850
# higher up to handle
3849
3851
pass
@@ -3862,12 +3864,10 @@ def _add_numeric_methods_binary(cls):
3862
3864
3863
3865
def _make_evaluate_binop (op , opstr , reversed = False , constructor = Index ):
3864
3866
def _evaluate_numeric_binop (self , other ):
3865
-
3866
- from pandas .tseries .offsets import DateOffset
3867
3867
other = self ._validate_for_numeric_binop (other , op , opstr )
3868
3868
3869
3869
# handle time-based others
3870
- if isinstance (other , (DateOffset , np .timedelta64 ,
3870
+ if isinstance (other , (ABCDateOffset , np .timedelta64 ,
3871
3871
Timedelta , datetime .timedelta )):
3872
3872
return self ._evaluate_with_timedelta_like (other , op , opstr )
3873
3873
elif isinstance (other , (Timestamp , np .datetime64 )):
0 commit comments