title: Why is column order not preserved when handling a csv file with pandas?
body: <p>There are a number of questions here on SO regarding <code>pandas</code> not respecting the order of the columns when reading/writing a csv file, some of them dating back 5 years ago (!):</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/15653688/preserving-column-order-in-python-pandas-dataframe">Preserving column order in Python Pandas DataFrame</a></li>
  <li><a href="https://stackoverflow.com/questions/31130235/python-pandas-read-csv-keep-column-order">Python Pandas read_csv Keep Column Order</a></li>
  <li><a href="https://stackoverflow.com/questions/40024406/keeping-columns-in-the-specified-order-when-using-usecols-in-pandas-read-csv">Keeping columns in the specified order when using UseCols in Pandas Read_CSV</a></li>
  </ul>
  
  <p>According to <a href="https://stackoverflow.com/a/16958464/1391441">this answer</a>, this "bug" was fixed with version 0.19.0 but I'm running Python 3.6.4 and <code>pandas</code> 0.22.0 and I still encounter this issue.</p>
  
  <p>Is this a bug that's been around for years or is this just how <code>pandas</code> work? If so, what's the reasoning behind not preserving column order?</p>
  
  <hr>
  
  <p>You can reproduce the issue with <a href="https://pastebin.com/CknatfRg" rel="nofollow noreferrer">this csv file</a> and the following code:</p>
  
  <pre><code>import pandas as pd
  df = pd.read_csv(
      "test.csv", usecols=('Author', 'Title', 'Abstract Note', 'Url'))
  print(df)
  </code></pre>
  
  <p>Notice that the <code>'Url'</code> is not positioned last in <code>df</code> as it should.</p>