Skip to content

Commit a0289ad

Browse files
authored
1 parent c01304a commit a0289ad

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

pandas/core/missing.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,18 @@ def mask_missing(arr: ArrayLike, values_to_mask) -> npt.NDArray[np.bool_]:
125125
new_mask[arr_mask] = arr[arr_mask] == x
126126
else:
127127
# GH#47101
128-
# Fix where type 'bool' has no attribute 'to_numpy()' by first attempting to broadcast
129-
# with np.equal for some cases, and then an explicit type check when checking the mask
130-
# for any straggling cases
128+
# Fix where type 'bool' has no attribute 'to_numpy()' by first
129+
# attempting to broadcast with np.equal for some cases, and then
130+
# an explicit type check when checking the mask for any straggling
131+
# cases
131132
new_mask = np.equal(arr, x)
132133

133134
if not isinstance(new_mask, np.ndarray):
134135
# usually BooleanArray
135-
new_mask = np.array([new_mask]) if isinstance(new_mask, bool) else new_mask.to_numpy(dtype=bool, na_value=False)
136+
if isinstance(new_mask, bool):
137+
new_mask = np.array([new_mask])
138+
else:
139+
new_mask = new_mask.to_numpy(dtype=bool, na_value=False)
136140
mask |= new_mask
137141

138142
if na_mask.any():

0 commit comments

Comments
 (0)