I have two dataframes, and one bigger dataframe needs to be updated based on data from smaller dataframe. So basically if there is a record with matching names I want to update the price in df1, just like in an example below. There might be multiple rows with the same name in df1
df1
id name price
1 name_1 5,34
2 name_2 5,36
3 name_3 4,74
4 name_4 5,23
5 name_5 5,94
6 name_1 5,34
df2
name price
name_4 5,17
name_1 5,37
df_result
id name price
1 name_1 5,37
2 name_2 5,36
3 name_3 4,74
4 name_4 5,17
5 name_5 5,94
6 name_1 5,37
I'm quite stuck. Tried doing this with df.loc[] but I got nowhere. Any ideas?
Tried doing this with df.loc[] but I got nowhere- add the code from you attempt to your questionpd.concat([df1,df2]).drop_duplicates(subset=['name'], keep='last')df1.merge(df2, on="name", how="left").ffill(axis=1).drop("price_x", axis=1)"id"column on the replaced rows (nor the index if that matters). I'm not sure this is an exact duplicate.