Having 2 columns , I want to map values from column3 to column1 if there is no value in column1, if column3 is also blank then no value will be mapped.
Input Data
column1 column2 column3
2225 India 2227
UK 35604
32578 USA 38956
Dubai
7528 Bhutan
India 37890
Expected Output:
column1 column2 column3
2225 India 2227
35604 UK 35604
32578 USA 38956
Dubai
7528 Bhutan
37890 India 37890
Script i am trying to use :
if df['column1'] = 'NaN':
df['column1'] = df['column3']
Please Suggest How i can map values from column3 to column1 if column1 is blank.
df['column1'] = df['column1'].fillna(df['column3'])?df['column1'] = df['column3']???df['col1']isnan, then it is already different fromdf['col3']. Where it is notnan, you also want to replace by the value incolumn3? Then that's just what I posted.