我打算创建一个表来比较两个数据帧的内容。索引是流程的一部分,顺序已预定义。我的数据帧如下所示:
df1:
df2:
预期合并输出:
我尝试了两个指数的并集,即
index_all = df1.index.union(df2.index, sort=False)
然而,这些指数被分类为 |索引1 |索引2 |内容1 |内容2 | ------| ------- | -------- | -------- |xxa | xxa | 0 | 1 |初始|初始| 1 | 1 |泰伊| | 2| |ddas | | 3| |gsdj | gsdj | 4 | 6 |哈斯夫|哈斯夫| 5 | 5 || fafa | 6 || eafa | 7
像这样的东西怎么样:
设置
join
使用
outer
相关问题 更多 >
编程相关推荐