You can use loc to exchange:
df.loc[df['Col3'].isnull(), ['Col2', 'Col3']] = df.loc[df['Col3'].isnull(), ['Col3', 'Col2']].values
Note that .values is required to ensure that the .values is done correctly, otherwise Pandas will try to align the names of indexes and columns, and no exchange will occur.
You can also just reassign each line separately if you think the code is cleaner:
null_idx = df['Col3'].isnull() df.loc[null_idx, 'Col3'] = df['Col2'] df.loc[null_idx, 'Col2'] = np.nan
Result:
Col1 Col2 Col3 0 A NaN 7.0 1 B NaN 16.0 2 B 16.0 15.0
source share