filling data in from another column

26 May 2018

see here:

in short, if you want to replace all the column As with column Bs, but only in rows where column D is equivalent to ‘Test’, use:

df_copy.loc[df['D']=='Test', 'A'] = df['B']

if you just wanted to fill nas from another column:

df['A'] = df['A'].fillna(df['B'])