Skip to content

Commit 80aad0d

Browse files
committed
COMPAT: work around deprecation warning on non-equal dtype comparisons
closes #20011
1 parent 33173a4 commit 80aad0d

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

pandas/core/indexes/base.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,14 @@ def cmp_method(self, other):
9999
# don't pass MultiIndex
100100
with np.errstate(all='ignore'):
101101
result = ops._comp_method_OBJECT_ARRAY(op, self.values, other)
102+
102103
else:
103-
with np.errstate(all='ignore'):
104-
result = op(self.values, np.asarray(other))
104+
105+
# numpy will show a DeprecationWarning on invalid elementwise
106+
# comparisons, this will raise in the future
107+
with warnings.catch_warnings(record=True):
108+
with np.errstate(all='ignore'):
109+
result = op(self.values, np.asarray(other))
105110

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

0 commit comments

Comments
 (0)