Dataframe 1:
| i | a | b | c |
|---|---|---|---|
| 1 | foo | 1 | 3 |
| 2 | foo | 1 | 3 |
| 3 | bar | 1 | 3 |
| 4 | foo | 1 | 3 |
| 5 | foo | 1 | 3 |
| 6 | baz | 1 | 3 |
Dataframe 2:
| i | 1 | 2 |
|---|---|---|
| 1 | foo | i'm foo |
| 2 | bar | i'm bar |
| 3 | baz | i'm baz |
Resulting Dataframe1:
| i | a | b | c | new column |
|---|---|---|---|---|
| 1 | foo | 1 | 3 | i'm foo |
| 2 | foo | 1 | 3 | i'm foo |
| 3 | bar | 1 | 3 | i'm bar |
| 4 | foo | 1 | 3 | i'm foo |
| 5 | foo | 1 | 3 | i'm foo |
| 6 | baz | 1 | 3 | i'm baz |
Hello guys, I couldn't find the answer to this specific problem, Hope you guys can help. I want to append column from dataframe2 to dataframe1 depending on this condition:
If dataframe1 column 'a' matches with dataframe2 column '1', append dataframe2 column '2' to dataframe1
I can try iterating both dataframes and fill in the values but that would not be efficient at all.
Awaiting your responses, Let me know if I missed any detail.
Thank you