I have the following dataframe in:
a
1 3
2 2
3 Nan
4 3
5 Nan
I need to recode this column so it looks like this:
df_miss_a
1 0
2 0
3 1
4 0
5 1
I've tried:
df_miss_a = np.where(df['a'] == 'Nan', 1, 0)
and
df_miss_a = np.where(df['a'] == Nan, 1, 0)
The above outputs only 0s.
The format of the output is unimportant.
replaceorfillna) only solve part of OP's problem; namely replacing all values that are NaN. However, OP also wants to replace all values that are not NaN.