title: Adding a column to pandas dataframe using dictionary with indices
body: <p>This must be trivial but I just can't find it.</p>
  <p>For a given pandas <code>dataframe</code> with some indices, say <code>idx1</code>,<code>idx2</code>,<code>idx3</code> I would like to add a new column efficiently using a dictionary, so something like this:</p>
  <p>What is the best way to do it?</p>
  <pre><code>have = pd.DataFrame({&quot;idx1&quot;:{&quot;c1&quot;:1,&quot;c2&quot;:2}, \
                       &quot;idx2&quot;:{&quot;c1&quot;:3,&quot;c2&quot;:4}, \
                       &quot;idx3&quot;:{&quot;c1&quot;:5,&quot;c2&quot;:6}}).transpose()
  newColumn = {&quot;idx1&quot;:&quot;col&quot;,&quot;idx2&quot;:&quot;to&quot;,&quot;idx3&quot;:&quot;add&quot;}
  columnName = &quot;myName&quot;
  
  #Wished output:
  want = pd.DataFrame({&quot;idx1&quot;:{&quot;c1&quot;:1,&quot;c2&quot;:2,&quot;myName&quot;:&quot;col&quot;}, \
                    &quot;idx2&quot;:{&quot;c1&quot;:3,&quot;c2&quot;:4,&quot;myName&quot;:&quot;to&quot;}, \
                    &quot;idx3&quot;:{&quot;c1&quot;:5,&quot;c2&quot;:6,&quot;myName&quot;:&quot;add&quot;}}).transpose()
  </code></pre>