We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 6a18b99 commit 533d841Copy full SHA for 533d841
pandas/core/construction.py
@@ -502,12 +502,12 @@ def sanitize_masked_array(data: ma.MaskedArray) -> np.ndarray:
502
if mask.any():
503
dtype, fill_value = maybe_promote(data.dtype, np.nan)
504
dtype = cast(np.dtype, dtype)
505
- data = ma.asarray(data.astype(dtype, copy=True))
506
- data.soften_mask() # set hardmask False if it was True
507
- data[mask] = fill_value
+ sanitized_ma = data.astype(dtype, copy=True)
+ sanitized_ma.soften_mask() # set hardmask False if it was True
+ sanitized_ma[mask] = fill_value
508
+ return sanitized_ma
509
else:
- data = data.copy()
510
- return data
+ return data.copy()
511
512
513
def sanitize_array(
0 commit comments