title: Writing multiple dictionaries to csv file?
body: <p>Thanks to this other thread, I've successfully written my dictionary to a csv as a beginner using Python:
  <a href="https://stackoverflow.com/questions/8685809/writing-a-dictionary-to-a-csv-file-with-one-line-for-every-key-value">Writing a dictionary to a csv file with one line for every &#39;key: value&#39;</a></p>
  
  <pre><code>dict1 = {0 : 24.7548, 1: 34.2422, 2: 19.3290}
  </code></pre>
  
  <p>csv looks like this:</p>
  
  <pre class="lang-none prettyprint-override"><code>0  24.7548
  1  34.2422
  2  19.3290
  </code></pre>
  
  <p>Now, i'm wondering what would be the best approach to organize several dictionaries with the same keys. I'm looking to have the keys as a first column, then the dict values in columns after that, all with a first row to distinguish the columns by dictionary names.</p>
  
  <p>Sure, there are a lot of threads trying to do similar things, such as: <a href="https://stackoverflow.com/questions/15440970/trouble-writing-a-dictionary-to-csv-with-keys-as-headers-and-values-as-columns">Trouble writing a dictionary to csv with keys as headers and values as columns</a>, but don't have my data structured in the same way (yet…). Maybe the dictionaries must be merged first.</p>
  
  <pre><code>dict2 = {0 : 13.422, 1 : 9.2308, 2 : 20.132}
  dict3 = {0 : 32.2422, 1 : 23.342, 2 : 32.424}
  </code></pre>
  
  <p>My ideal output:</p>
  
  <pre class="lang-none prettyprint-override"><code>ID  dict1    dict2    dict3
  0   24.7548  13.422   32.2422
  1   34.2422  9.2308   23.342
  2   19.3290  20.132   32.424
  </code></pre>
  
  <p>I'm not sure, yet, how the column name <code>ID</code> for key names will work its way in there.</p>