I have null (nan) values in column A and would like to assign 0 to the cells in column B when a cell of the same row in column A is null.
Column B has been created as the following lambda expression :
df['col_B'] = df.apply(lambda x: x.col_A in x.col_C, axis=1)
I tried to modify it but it doesn't work and from what I read it isn't advised.
So I tried with a classic loop, it shows no error but it doesn't modify the cells in column B :
for index, row in df.iterrows():
if row['col_A'] is None:
df.at[index, 'col_B'] = 0
My null values appear as "nan" (not "None" or "Nan") so I'm not even sure Python considers them as real null values.
What would you advise ?