I have 2 dataframes:
df1
id value value_2
1 A 100
2 B 200
3 C 300
4 D 400
5 F 500
df2
id value value_2 many_irrelevant_collumns
1 nan NaN ...
2 B 200 ...
3 CCC 5000 ...
4 D 400 ...
5 FFF 50000 ...
I am trying to update columns value & value_2
from df1
to df2
on id
so that the result looks like this:
id value value_2 many_irrelevant_collumns
1 A 100 ...
2 B 200 ...
3 C 300 ...
4 D 400 ...
5 F 500 ...
I tried:
pd.merge(df1, df2, how='left',on='id')
But this just adds the columns instead of updating the value. I am not sure if pd.merge
is how this should be done.