How to convert pandas <NA> to numy Nan?

Viewed 2229

I have following data set

enter image description here

I would like to convert float values to int, so i did data.convert_dtypes()

enter image description here

Pandas converted Nan to Na. How can i make it back or prevent pandas to do it? I use data imputation and some algorithmes doesn't support ( 'bool' object has no attribute 'transpose' )

I tried replace, fillna . Replace({pd.NA: np.nan}) convert int to float back again and this is not my solution since i would like to work with int

1 Answers

If need np.nan what is float need your solution, but NA inetegers columns are converted to floats columns:

df = df.replace({pd.NA: np.nan})

If need integers, onky ways is replace NA to some integer:

df = df.replace(pd.NA, -1)
Related