Skip to content

Commit 5812073

Browse files
committed
COMPAT: work around deprecation warning on non-equal dtype comparisons
closes pandas-dev#20011
1 parent e3f6a5b commit 5812073

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

pandas/core/indexes/base.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,19 @@ def cmp_method(self, other):
9595
if needs_i8_conversion(self) and needs_i8_conversion(other):
9696
return self._evaluate_compare(other, op)
9797

98+
other = np.asarray(other)
9899
if is_object_dtype(self) and self.nlevels == 1:
99100
# don't pass MultiIndex
100101
with np.errstate(all='ignore'):
101102
result = ops._comp_method_OBJECT_ARRAY(op, self.values, other)
103+
104+
elif self.values.dtype.type != other.dtype.type:
105+
# short-circuit on dtype inequity
106+
result = op is not operator.eq
107+
102108
else:
103109
with np.errstate(all='ignore'):
104-
result = op(self.values, np.asarray(other))
110+
result = op(self.values, other)
105111

106112
# technically we could support bool dtyped Index
107113
# for now just return the indexing array directly

0 commit comments

Comments
 (0)