I'd like to modify dataframe when value in column = NaN. When I try this solution:
if df['columnx'].isnull().values.any():
df['columnx'] = df['columnz']
all the columns seem to be converted, not only when meeting the criteria of NaN value.
This is what I get if I print the columnx values:
1 12345
2 12346
3 12347
4 NaN
5 NaN
6 NaN
When df['columnz'] has:
4 12355
5 12356
6 12357
I only want the the:
4 NaN
5 NaN
6 NaN
So I can convert
df['columnx'] = df['columnz']
So that I have df['columnx']:
1 12345
2 12346
3 12347
4 12355
5 12356
6 12357