title: How to write a "key" column with seperately with each other column to csv in python
body: <p>In Python I want to break up one data-frame and write -each "Key","Column" pair to a CSV file. The rows also sometimes contain more than one value per column.</p>
  
  <p>The data-frame looks as follows (the number of columns will not always be the same)</p>
  
  <pre><code>col1     col2     key    col3
  a        b        c      d
  a1       b1       c1     d1,d4
  a2       b2,b4    c2     d2
  a3       b3       c3     d3
  </code></pre>
  
  <p>What I need is 3 CSV files, looking as follows:</p>
  
  <pre><code>col.csv
  key    col1
  c      a
  c1     a1
  c2     a2
  c3     a3
  
  col2.csv
  key    col2
  c      b
  c1     b1
  c2     b2
  c2     b4
  c3     b3
  
  col3.csv
  key    col3
  c      d
  c1     d1
  c1     d4
  c2     d2
  c3     d3 
  </code></pre>
  
  <p>What I've done is write out each column to CSV, with the column name as the CSV, I however cannot get the "key" column to the CSV's.  </p>
  
  <pre><code>z = df[df_obj.columns]
  
  for c in z.columns:
      df[c].to_csv(cwd + '/split/' + c + '.csv', index=False)
  </code></pre>
  
  <p>What I get is:</p>
  
  <pre><code>col1.csv
  col1
  a
  a1
  a2
  a3
  
  col2.csv
  col2
  b
  b1
  b2,b4
  b3
  
  col3.csv
  col3
  d
  d1,d4
  d2
  d3 
  </code></pre>