Skip to content

Commit 8340f09

Browse files
committed
first
1 parent e49ab80 commit 8340f09

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

pandas/core/construction.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
maybe_cast_to_integer_array,
3333
maybe_convert_platform,
3434
maybe_infer_to_datetimelike,
35-
maybe_promote,
3635
)
3736
from pandas.core.dtypes.common import (
3837
ensure_object,
@@ -513,10 +512,17 @@ def sanitize_masked_array(data: ma.MaskedArray) -> np.ndarray:
513512
"""
514513
mask = ma.getmaskarray(data)
515514
if mask.any():
516-
dtype, fill_value = maybe_promote(data.dtype, np.nan)
517-
dtype = cast(np.dtype, dtype)
515+
dtype = cast(np.dtype, data.dtype)
518516
data = ma.asarray(data.astype(dtype, copy=True))
519517
data.soften_mask() # set hardmask False if it was True
518+
519+
if np.issubdtype(dtype, np.integer):
520+
fill_value: int | float | None = np.iinfo(dtype).min
521+
elif np.issubdtype(dtype, np.floating):
522+
fill_value = np.nan
523+
else:
524+
fill_value = None
525+
520526
data[mask] = fill_value
521527
else:
522528
data = data.copy()

0 commit comments

Comments
 (0)