'How to create dataframe using two dataframe using pandas
I have two dataframe 'df1' and 'df2'
df1= a b
1 such as
2 who I'm
df2= a keyword
1 such
1 as
2 who
2 I'm
Based on this two dataframe I want to create following dataframe
result = a keyword
such as such
such as as
who I'm who
who I'm I'm
Solution 1:[1]
IIUC, just perform a replacement with map:
df2['a'] = df2['a'].map(df1.set_index('a')['b'])
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | mozway |
