Column order in pandas.concat

后端 未结 6 1669
既然无缘
既然无缘 2021-02-04 00:26

I do as below:

data1 = pd.DataFrame({ \'b\' : [1, 1, 1], \'a\' : [2, 2, 2]})
data2 = pd.DataFrame({ \'b\' : [1, 1, 1], \'a\' : [2, 2, 2]})
frames = [data1, data2         


        
6条回答
  •  悲哀的现实
    2021-02-04 00:50

    Simplest way is firstly make the columns same order then concat:

    df2=df2[df1.columns]
    df=pd.concat((df1,df2),axis=0)
    

提交回复
热议问题