我问的问题类似于this one,但我需要一些不同的东西。我有两个pandas.DataFrames
,我需要合并它们。
这是第一个df_1
:
id attr fruit_list
---------------------------------------
0 42 [orange, apple]
1 57 [lemon]
2 86 [kiwi]
3 33 [pineapple, pear]
4 11 [apple, lemon]
这是第二个df_2
:
id fruit_list
--------------------------------------
0 [fruit1,]
1 [fruit4, fruit2]
2 [fruit2, fruit8]
3 [fruit3,]
4 [fruit3,]
我需要合并这两个DataFrames
以获得如下输出:
id attr fruit_list
---------------------------------------------
0 42 [orange, apple, fruit1]
1 57 [lemon, fruit4, fruit2]
2 86 [kiwi, fruit2, fruit8]
3 33 [pineapple, pear, fruit3]
4 11 [apple, lemon, fruit3]
我怎么能实现这个目标?我看过documentation,但我找不到办法。