I have two different data frames composed of strings (several thousands of rows). They each have a different number of entries. I am trying to find a code that will allow me to associate the content of the column "characteristic" in df2 into df1 (see example below) :
Df1 :
ID | Information |
---|---|
11AA | info1 |
22BB | info2 |
33CC | info3 |
44DD | info4 |
11AA | info1 |
22BB | info2 |
Df2:
ID | Characteristic |
---|---|
11AA | char1 |
22BB | char2 |
33CC | char3 |
44DD | char4 |
The intended result would be :
Df3:
ID | Information | Characteristic |
---|---|---|
11AA | info1 | char1 |
22BB | info2 | char2 |
33CC | info3 | char3 |
44DD | info4 | char4 |
11AA | info1 | char1 |
22BB | info2 | char2 |
I tried using inner_join(df1,df2, by="ID") but the resulting dataframe (df3) often has more rows than the original (df1) and I need that the resulting dataframe (df3) keeps the same structure than the original one (df1), I just need to add the extra column.
Is there a built in function for this type of operation?