I have a column in dataframe of data type object which basically composed of a lot of missing values as NaN and some strings as 'False' and 'True' entries. I want to convert it to boolean data type but the NaN entries get converted to True. How to Do this with preserving the NaN values as it is?
1- I've tried the .astype() method which returned the NaN values as True. 2- Tried to convert first to numeric then to boolean and ended up with the same result.
# Before conversion
In[]:  ri_df.contraband_weapons.value_counts()
Out[]: False    11296
       True       499
       Name: contraband_weapons, dtype: int64
# After conversion
In[]:  ri_df.contraband_weapons.astype('bool').value_counts()
Out[]: True     498385
       False     11296
       Name: contraband_weapons, dtype: int64
 
     
     
    