File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change 32
32
maybe_cast_to_integer_array ,
33
33
maybe_convert_platform ,
34
34
maybe_infer_to_datetimelike ,
35
- maybe_promote ,
36
35
)
37
36
from pandas .core .dtypes .common import (
38
37
ensure_object ,
@@ -513,10 +512,17 @@ def sanitize_masked_array(data: ma.MaskedArray) -> np.ndarray:
513
512
"""
514
513
mask = ma .getmaskarray (data )
515
514
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 )
518
516
data = ma .asarray (data .astype (dtype , copy = True ))
519
517
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
+
520
526
data [mask ] = fill_value
521
527
else :
522
528
data = data .copy ()
You can’t perform that action at this time.
0 commit comments