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 3232 maybe_cast_to_integer_array ,
3333 maybe_convert_platform ,
3434 maybe_infer_to_datetimelike ,
35- maybe_promote ,
3635)
3736from 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 ()
You can’t perform that action at this time.
0 commit comments