title: Why the column order is changing while appending pandas dataframes?
body: <p>I want to append (merge) all the csv files in a folder using Python pandas.</p>
  
  <p>For example: Say folder has two csv files <code>test1.csv</code> and <code>test2.csv</code> as follows:</p>
  
  <pre><code>A_Id    P_Id    CN1         CN2         CN3
  AAA     111     702         709         740
  BBB     222     1727        1734        1778
  </code></pre>
  
  <p>and</p>
  
  <pre><code>A_Id    P_Id    CN1         CN2         CN3
  CCC     333     710        750          750
  DDD     444     180        734          778
  </code></pre>
  
  <p>So the python script I wrote was as follows:</p>
  
  <pre><code>#!/usr/bin/python
  import pandas as pd
  import glob
  
  all_data = pd.DataFrame()
  for f in glob.glob("testfolder/*.csv"):
      df = pd.read_csv(f)
      all_data = all_data.append(df)
  
  all_data.to_csv('testfolder/combined.csv')
  </code></pre>
  
  <p>Though the <code>combined.csv</code> seems to have all the appended rows, it looks as follows:  </p>
  
  <pre><code>      CN1       CN2         CN3    A_Id    P_Id
    0   710      750         750     CCC     333
    1   180       734         778     DDD     444     
    0   702       709         740     AAA     111
    1  1727       1734        1778    BBB     222
  </code></pre>
  
  <p>Where as it should look like this:</p>
  
  <pre><code>A_ID   P_Id   CN1    CN2    CN2
  AAA    111    702    709    740
  BBB    222    1727   1734   1778
  CCC    333    110    356    123
  DDD    444    220    256    223
  </code></pre>
  
  <ul>
  <li><strong>Why are the first two columns moved to the end?</strong></li>
  <li><strong>Why is it appending in the first line rather than at the last line?</strong></li>
  </ul>
  
  <p>What am I missing? And how can I get get of 0s and 1s in the first column?</p>
  
  <p>P.S: Since these are large csv files, I thought of using pandas.</p>