File tree 1 file changed +13
-1
lines changed
1 file changed +13
-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,13 +96,24 @@ 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
99
+ other = np .asarray (other )
100
+ self_dtype = self .values .dtype
101
+ other_dtype = other .dtype
102
+
98
103
if is_object_dtype (self ) and self .nlevels == 1 :
99
104
# don't pass MultiIndex
100
105
with np .errstate (all = 'ignore' ):
101
106
result = ops ._comp_method_OBJECT_ARRAY (op , self .values , other )
107
+
108
+ elif ((self_dtype .type != other_dtype .type ) and not
109
+ (is_numeric_dtype (self_dtype ) and
110
+ is_numeric_dtype (other_dtype ))):
111
+ # short-circuit on dtype inequity
112
+ result = op is not operator .eq
113
+
102
114
else :
103
115
with np .errstate (all = 'ignore' ):
104
- result = op (self .values , np . asarray ( other ) )
116
+ result = op (self .values , other )
105
117
106
118
# technically we could support bool dtyped Index
107
119
# for now just return the indexing array directly
You can’t perform that action at this time.
0 commit comments