MCPcopy
hub / github.com/pandas-dev/pandas / sanitize_masked_array

Function sanitize_masked_array

pandas/core/construction.py:515–528  ·  view source on GitHub ↗

Convert numpy MaskedArray to ensure mask is softened.

(data: ma.MaskedArray)

Source from the content-addressed store, hash-verified

513
514
515def sanitize_masked_array(data: ma.MaskedArray) -> np.ndarray:
516 """
517 Convert numpy MaskedArray to ensure mask is softened.
518 """
519 mask = ma.getmaskarray(data)
520 if mask.any():
521 dtype, fill_value = maybe_promote(data.dtype, np.nan)
522 dtype = cast(np.dtype, dtype)
523 data = ma.asarray(data.astype(dtype, copy=True))
524 data.soften_mask() # set hardmask False if it was True
525 data[mask] = fill_value
526 else:
527 data = data.copy()
528 return data
529
530
531def sanitize_array(

Callers 2

__init__Method · 0.90
sanitize_arrayFunction · 0.85

Calls 4

maybe_promoteFunction · 0.90
anyMethod · 0.45
astypeMethod · 0.45
copyMethod · 0.45

Tested by

no test coverage detected