Skip to content

Commit febffcb

Browse files
author
Vítor Araujo
committed
BUG: Replace method raising error in col with pd.NA (#47480)
1 parent c30bd01 commit febffcb

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

pandas/core/missing.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,11 @@ def mask_missing(arr: ArrayLike, values_to_mask) -> npt.NDArray[np.bool_]:
9393
# GH#29553 prevent numpy deprecation warnings
9494
pass
9595
else:
96-
new_mask = arr == x
9796
# GH#47480
98-
if isinstance(new_mask, bool):
99-
new_mask = np.equal(arr, x, dtype=object)
100-
mask_na = np.vectorize(lambda value: False if isna(value) else value)
101-
new_mask = mask_na(new_mask).astype(bool)
97+
mask_func = np.vectorize(
98+
lambda value: False if (isna(value) or value != x) else True
99+
)
100+
new_mask = mask_func(arr).astype(bool)
102101
if not isinstance(new_mask, np.ndarray):
103102
# usually BooleanArray
104103
new_mask = new_mask.to_numpy(dtype=bool, na_value=False)

0 commit comments

Comments
 (0)