0

can you please tell me about this question: I have a dataframe

enter image description here

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?

Sam324
  • 199
  • 4
  • 13

1 Answers1

0

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'])
U13-Forward
  • 69,221
  • 14
  • 89
  • 114