I have a dataframe with mixed datatypes. I would like to fill NaN values but keep None values as the same.
I tried to use fillna() method from pandas but the function is filling both NaN and None values. I want to fill NaN with a specific string value like 'x', instead of numbers. And keep None values as the same.
For example:
A B C
0 12 0 None
1 None NaN None
2 NaN 9.8 1
3 0 NaN 1
Expected:
A B C
0 12 0 None
1 None x None
2 x 9.8 1
3 0 x 1
and then use this below code segment to change None to 'None' (a string) and then replace NA with which ever values you want to replace it with.
the finally converting it back to None (not a string)
result looks like this