can you please tell me about this question: I have a dataframe
I want to do the following with it: if the line in the proba column is nan, then change the value in the corresponding line in the flag column to 0. How can I do this?
Try with isna
and loc
:
df.loc[df['proba'].isna(), 'flag'] = 0
Or np.where
:
df['flag'] = np.where(df['proba'].isna(), 0, df['flag'])