Skip to content

Commit 6f90ac3

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

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

pandas/core/missing.py

+5-14
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
from pandas.core.dtypes.cast import infer_dtype_from
3232
from pandas.core.dtypes.common import (
3333
is_array_like,
34-
is_numeric_v_string_like,
3534
needs_i8_conversion,
3635
)
3736
from pandas.core.dtypes.missing import (
@@ -89,19 +88,11 @@ def mask_missing(arr: ArrayLike, values_to_mask) -> npt.NDArray[np.bool_]:
8988
# GH 21977
9089
mask = np.zeros(arr.shape, dtype=bool)
9190
for x in nonna:
92-
if is_numeric_v_string_like(arr, x):
93-
# GH#29553 prevent numpy deprecation warnings
94-
pass
95-
else:
96-
# GH#47480
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)
101-
if not isinstance(new_mask, np.ndarray):
102-
# usually BooleanArray
103-
new_mask = new_mask.to_numpy(dtype=bool, na_value=False)
104-
mask |= new_mask
91+
# GH#47480
92+
new_mask = np.vectorize(
93+
lambda value: False if (isna(value) or value != x) else True
94+
)(arr)
95+
mask |= new_mask
10596

10697
if na_mask.any():
10798
mask |= isna(arr)

0 commit comments

Comments
 (0)