Appending two dataframes with same columns, different order

前端 未结 3 1696
梦毁少年i
梦毁少年i 2021-02-01 14:23

I have two pandas dataframes.

noclickDF = DataFrame([[0,123,321],[0,1543,432]], columns=[\'click\', \'id\',\'location\'])
clickDF = DataFrame([[1,123,421],[1,154         


        
3条回答
  •  执笔经年
    2021-02-01 15:18

    You can use append for that

     df = noclickDF.append(clickDF)
     print df 
    
        click    id  location
     0      0   123       321  
     1      0  1543       432
     0      1   421       123
     1      1   436      1543
    

    and if you need you can reset the index by

    df.reset_index(drop=True)
    print df
       click    id  location
    0      0   123       321
    1      0  1543       432
    2      1   421       123
    3      1   436      1543
    

提交回复
热议问题