Skip to content

Commit 3774ceb

Browse files
authored
Fix test TypeErrors
np.equal([1,2,3], "") fails
1 parent a0289ad commit 3774ceb

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

pandas/core/missing.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,11 @@ def mask_missing(arr: ArrayLike, values_to_mask) -> npt.NDArray[np.bool_]:
129129
# attempting to broadcast with np.equal for some cases, and then
130130
# an explicit type check when checking the mask for any straggling
131131
# cases
132-
new_mask = np.equal(arr, x)
132+
try:
133+
new_mask = np.equal(arr, x)
134+
except TypeError:
135+
# Old behaviour for uncastable types
136+
new_mask = arr == x
133137

134138
if not isinstance(new_mask, np.ndarray):
135139
# usually BooleanArray

0 commit comments

Comments
 (0)