pandas组合了多个数据帧或用作更新

时间:2013-02-22 22:56:27

标签: python pandas

有没有办法根据两者索引和列来连接,加入或合并数据帧?例如,假设我有一个数据帧列表,我想要像

这样的东西
df = pandas.fullConcat(dfList)

其中df.index应该是dfList('outer'join)中索引的并集,而df.columns也应该是dfList中列的并集。我认为所有concat,join和merge方法只是在索引或列上进行连接。我想一个解决方法是stack / unstack或reset_index?我觉得我错过了一些简单的东西。

1 个答案:

答案 0 :(得分:2)

我认为您将不得不重置索引:

df = df1.reset_index().merge(df2.reset_index(), on=['index','cols']).set_index('index')