I have 2 dataframes:
ID | Name | Category---- |
---|---|---|
1 | Apple | Fruit |
2 | Orange | Fruit |
3 | brocolli | Vegetable |
4 | Spinach | Vegetable |
DF2型
UserID | Date | UserName | Description |
---|---|---|---|
111 | 01/01/2020 | AAA | Ordered 1 Box Apples |
111 | 01/02/2021 | AAA | Ordered 1KG spinach |
222 | 15/03/2021 | BBB | Ordered 3 boxes of Orange |
Can anyone help how I can match the "Description" from DF2型 which contains "Name" string from DF1 and add the respective "Category" column in DF2型?
期望输出:
UserID | Date | UserName | Description | Category |
---|---|---|---|---|
111 | 01/01/2020 | AAA | Ordered 1 Box Apples | Fruit |
111 | 01/02/2021 | AAA | Ordered 1KG spinach | Vegetable |
222 | 15/03/2021 | BBB | Ordered 3 boxes of Orange | Fruit |