I have the following two tables df1:
| id | description |
|---|---|
| 1 | Foo |
| 2 | Bar |
and df2:
| description | category |
|---|---|
| Foo | cat1 |
| Barrista | cat2 |
I now want to merge the dfs based on the "description" column if the string in df2 contains the string of df1.
Right now I could only make it work with exact matches but not for contains cases:
df3 = df1.merge(df2, on='description', how='left', suffixes=('_1', '_2'))
which returns
| id | description | category |
|---|---|---|
| 1 | Foo | cat1 |
| 2 | Bar |
but the desired output df3 should look like:
| id | description | category |
|---|---|---|
| 1 | Foo | cat1 |
| 2 | Bar | cat2 |