File tree 1 file changed +12
-1
lines changed
1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change 42
42
is_datetime64_any_dtype ,
43
43
is_datetime64tz_dtype ,
44
44
is_timedelta64_dtype ,
45
+ is_numeric_dtype ,
45
46
needs_i8_conversion ,
46
47
is_iterator , is_list_like ,
47
48
is_scalar )
@@ -95,10 +96,20 @@ def cmp_method(self, other):
95
96
if needs_i8_conversion (self ) and needs_i8_conversion (other ):
96
97
return self ._evaluate_compare (other , op )
97
98
98
- if is_object_dtype (self ) and self .nlevels == 1 :
99
+ self_dtype = self .values .dtype
100
+ other_dtype = np .asarray (other ).dtype
101
+
102
+ if is_object_dtype (self_dtype ) and self .nlevels == 1 :
99
103
# don't pass MultiIndex
100
104
with np .errstate (all = 'ignore' ):
101
105
result = ops ._comp_method_OBJECT_ARRAY (op , self .values , other )
106
+
107
+ elif ((self_dtype .type != other_dtype .type ) and not
108
+ (is_numeric_dtype (self_dtype ) and
109
+ is_numeric_dtype (other_dtype ))):
110
+ # short-circuit on dtype inequity
111
+ result = op is not operator .eq
112
+
102
113
else :
103
114
with np .errstate (all = 'ignore' ):
104
115
result = op (self .values , np .asarray (other ))
You can’t perform that action at this time.
0 commit comments