Reputation: 1082
I would like to know how can I add a column in a dataframe and fill it with the values of another dataframe. Example:
df1:
Products Materials
1 A Wood
df2:
Price
Wood 1.02
I will get at the end:
df1:
Products Materials Price
1 A Wood 1.02
Thank you !
Upvotes: 0
Views: 83
Reputation: 210832
You can use Series.map method
df1['Price'] = df1['Materials'].map(df2['Price'])
UPDATE:
if your df2
is a Pandas.Series use the folowing code:
df1['Price'] = df1['Materials'].map(df2)
Upvotes: 3