I have 2 dataframes like so:
df1
Name | Animal |
---|---|
John | Dog |
John | Cat |
John | Horse |
Mary | Dog |
Mary | Cat |
Mary | Horse |
df2
Name | Color |
---|---|
John | Blue |
Mary | Red |
I would like to merge them such that:
df3
Name | Animal | Color |
---|---|---|
John | Dog | Blue |
John | Cat | Blue |
John | Horse | Blue |
Mary | Dog | Red |
Mary | Cat | Red |
Mary | Horse | Red |
What would be the clearest way to go about this? I've tried multiple permutations of concat(), append(), merge(), and join() functions to no avail. I'm sure it has to be something simple, but most of the literature around this focuses on subsetting and eliminating duplicates, but not adding them.