Append Level to Column Index in python pandas

故事扮演 提交于 2019-12-03 13:00:26

I you want a MultiIndex, you can do this directly in the concat function to get the same results, like:

pd.concat([df1, df2, df3], axis=1, keys=['df1', 'df2', 'df3'])

or

pd.concat({'df1':df1, 'df2':df2, 'df3':df3}, axis=1)

See also Multi-index dataframe from sequence of dataframes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!