结合两个具有相同索引的Pandas数据框 [英] Combine two Pandas dataframes with the same index
本文介绍了结合两个具有相同索引的Pandas数据框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两个具有相同索引但不同列的数据框.如何将它们合并为具有相同索引但包含所有列的索引?
I have two dataframes with the same index but different columns. How do I combine them into one with the same index but containing all the columns?
我有:
A
1 10
2 11
B
1 20
2 21
,我需要以下输出:
A B
1 10 20
2 11 21
推荐答案
pandas.concat([df1, df2], axis=1)
这篇关于结合两个具有相同索引的Pandas数据框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文