Combine data frames with duplicate indexes
Is there a way to merge two dataframes while one of them has duplicate indices like:
dataframe A:
value
key
a 1
b 2
b 3
b 4
c 5
a 6
dataframe B:
number
key
a I
b X
c V
after the merge, I want to have a dataframe like below:
value number
key
a 1 I
b 2 X
b 3 X
b 4 X
c 5 V
a 6 I
Or maybe there are better ways to do this with groupby?
+3
source to share