We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 75a8d75 commit a9069f7Copy full SHA for a9069f7
pandas/core/common.py
@@ -359,20 +359,18 @@ def mask_missing(arr, values_to_mask):
359
if mask is None:
360
mask = arr == x
361
362
- # if x is a string and mask is not, then we get a scalar
363
- # return value, which is not good
364
- if not isinstance(mask, np.ndarray):
365
- m = mask
366
- mask = np.empty(arr.shape, dtype=np.bool)
367
- mask.fill(m)
+ # if x is a string and arr is not, then we get False and we must
+ # expand the mask to size arr.shape
+ if np.isscalar(mask):
+ mask = np.zeros(arr.shape, dtype=bool)
368
else:
369
- mask = mask | (arr == x)
+ mask |= arr == x
370
371
if na_mask.any():
372
373
mask = isnull(arr)
374
375
- mask = mask | isnull(arr)
+ mask |= isnull(arr)
376
377
return mask
378
0 commit comments