title: Appending CSV files, matching unordered columns
body: <p>Problem: matching columns while appending CSV files</p>
  
  <p>I have 50 .csv files where each column is a word, each row is a time of day and each file holds all words for one day. They look like this:</p>
  
  <pre><code>Date  Time Aword Bword Cword Dword
  Date1 t1   0     1     0     12
  Date1 t2   0     6     3     0
  
  Date  Time Eword Fword Gword Hword Bword
  Date2 t1   0     0     1     0     3
  Date2 t2   2     0     0     19    0
  </code></pre>
  
  <p>I want to append the files so that any columns with the same word (like Bword in this example) are matched while new words are added in new columns:</p>
  
  <pre><code>Date  Time Aword Bword Cword Dword Eword Fword Gword Hword
  Date1 t1   0     1     0     12                       
  Date1 t2   0     6     3     0                        
  Date2 t1         3                 0     0     1     0   
  Date2 t2         0                 2     0     0     19
  </code></pre>
  
  <p>I'm opening the csv files as dataframes to manipulate them and using dataframe.append the new files are added like this:</p>
  
  <pre><code>Date  Time Aword Bword Cword Dword
  Date1 t1   0     1     0     12
  Date1 t2   0     6     3     0
  Date  Time Eword Fword Gword Hword Bword
  Date2 t1   0     0     1     0     3
  Dat2e t2   2     0     0     19    0
  </code></pre>
  
  <p>Is there a different approach which could align matching columns while appending? ie without iterating through each column and checking for matches.</p>
  
  <p><em>Sincere apologies if this question is too vague, I'm new to python and still struggling to know when I'm thinking un-pythonically and when I'm using the wrong tools.</em></p>
  
  <p>EDIT: more information<br>
  1) I'll need to perform this task multiple times, once for each of five batches of csvs<br>
  2) The files all have 25 rows but have anything from 5 to 294 columns<br>
  3) The order of rows is important Day1(t1, t2...tn) then Day2(t1, t2...tn)<br>
  4) The order of columns is not important</p>