我需要比较两个 Dataframe df1和df2。如果df1中的名称等于df2中的名称,我需要将mylist合并到df2中。这是mylist datarame:
我的列表:
0 1
[1,2] [2,3]
[1,5] [2,6]
[1,6] [2,4]
[1,1] [2,5]
[1,3] [2,8]
mylist[0] = [[1,2],[2,3]]
mylist[1] = [[1,5],[2,6]]
这是 Dataframe df1:
df1:
name 0 1
0 a [1,2] [2,3]
1 y [1,5] [2,6]
2 c [1,6] [2,4]
3 x [1,10] [2,5]
4 e [1,3] [2,8]
这是 Dataframe df2:
df2:
name id
0 a abcd
1 b efgh
2 c ijkl
3 d mnop
4 e qrs
If the **name** in df1 = the **name** in df2, I need to append **mylist** in df1 to df2
预期输出=
df3:
name id 0 1
0 a abcd [1,2] [2,3]
1 b efgh
2 c ijkl [1,6] [2,4]
3 d mnop
4 e qrs [1,3] [2,8]
1条答案
按热度按时间zkure5ic1#
您可以使用合并: