Skip to content

Commit cb3c8d6

Browse files
Add check to verify whether arrays have the same type
1 parent 8db5a5f commit cb3c8d6

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

pandas/_libs/lib.pyx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,10 @@ def array_equivalent_object(left: object[:], right: object[:]) -> bool:
584584
# Only compare scalars to scalars and arrays to arrays
585585
elif cnp.PyArray_IsAnyScalar(x) != cnp.PyArray_IsAnyScalar(y):
586586
return False
587+
# Check if arrays have the same type
588+
elif not (cnp.PyArray_IsPythonScalar(x) or cnp.PyArray_IsPythonScalar(y)) \
589+
and not (isinstance(x, type(y)) or isinstance(y, type(x))):
590+
return False
587591
elif not (PyObject_RichCompareBool(x, y, Py_EQ) or
588592
(x is None or is_nan(x)) and (y is None or is_nan(y))):
589593
return False

0 commit comments

Comments
 (0)