17
17
from pandas .tslib import iNaT
18
18
from pandas .core .common import (bind_method , is_list_like , notnull , isnull ,
19
19
_values_from_object , _maybe_match_name ,
20
- needs_i8_conversion , is_integer_dtype )
20
+ needs_i8_conversion , is_datetimelike_v_integer , is_integer_dtype )
21
21
22
22
# -----------------------------------------------------------------------------
23
23
# Functions that add arithmetic methods to objects, given arithmetic factory
@@ -574,9 +574,7 @@ def na_op(x, y):
574
574
# we are not NotImplemented, otherwise
575
575
# we would allow datetime64 (but viewed as i8) against
576
576
# integer comparisons
577
- if needs_i8_conversion (x ) and (not isscalar (y ) and is_integer_dtype (y )):
578
- raise TypeError ("invalid type comparison" )
579
- elif (not isscalar (y ) and needs_i8_conversion (y )) and is_integer_dtype (x ):
577
+ if is_datetimelike_v_integer (x , y ):
580
578
raise TypeError ("invalid type comparison" )
581
579
582
580
# we have a datetime/timedelta and may need to convert
@@ -690,15 +688,15 @@ def na_op(x, y):
690
688
return result
691
689
692
690
def wrapper (self , other ):
693
- is_self_int_dtype = com . is_integer_dtype (self .dtype )
691
+ is_self_int_dtype = is_integer_dtype (self .dtype )
694
692
695
693
fill_int = lambda x : x .fillna (0 )
696
694
fill_bool = lambda x : x .fillna (False ).astype (bool )
697
695
698
696
if isinstance (other , pd .Series ):
699
697
name = _maybe_match_name (self , other )
700
698
other = other .reindex_like (self )
701
- is_other_int_dtype = com . is_integer_dtype (other .dtype )
699
+ is_other_int_dtype = is_integer_dtype (other .dtype )
702
700
other = fill_int (other ) if is_other_int_dtype else fill_bool (other )
703
701
704
702
filler = fill_int if is_self_int_dtype and is_other_int_dtype else fill_bool
@@ -711,7 +709,7 @@ def wrapper(self, other):
711
709
712
710
else :
713
711
# scalars, list, tuple, np.array
714
- filler = fill_int if is_self_int_dtype and com . is_integer_dtype (np .asarray (other )) else fill_bool
712
+ filler = fill_int if is_self_int_dtype and is_integer_dtype (np .asarray (other )) else fill_bool
715
713
return filler (self ._constructor (na_op (self .values , other ),
716
714
index = self .index )).__finalize__ (self )
717
715
0 commit comments