title: Unmelt Pandas DataFrame
body: <p>I have a pandas dataframe with two id variables:</p>
  
  <pre><code>df = pd.DataFrame({'id': [1,1,1,2,2,3], 
                 'num': [10,10,12,13,14,15],
                 'q': ['a', 'b', 'd', 'a', 'b', 'z'],
                 'v': [2,4,6,8,10,12]})
  
     id  num  q   v
  0   1   10  a   2
  1   1   10  b   4
  2   1   12  d   6
  3   2   13  a   8
  4   2   14  b  10
  5   3   15  z  12
  </code></pre>
  
  <p>I can pivot the table with:</p>
  
  <pre><code>df.pivot('id','q','v')
  </code></pre>
  
  <p>And end up with something close:</p>
  
  <pre><code>q    a   b   d   z
  id                
  1    2   4   6 NaN
  2    8  10 NaN NaN
  3  NaN NaN NaN  12
  </code></pre>
  
  <p>However, what I really want is (the original unmelted form):</p>
  
  <pre><code>id   num   a   b   d   z               
  1    10   2   4 NaN NaN
  1    12 NaN NaN   6 NaN  
  2    13   8 NaN NaN NaN
  2    14 NaN  10 NaN NaN
  3    15 NaN NaN NaN  12
  </code></pre>
  
  <p>In other words:</p>
  
  <ol>
  <li>'id' and 'num' my indices (normally, I've only seen either 'id' or 'num' being the index but I need both since I'm trying to retrieve the original unmelted form)</li>
  <li>'q' are my columns</li>
  <li>'v' are my values in the table</li>
  </ol>
  
  <p><strong>Update</strong></p>
  
  <p>I found a <strong>close</strong> solution from <a href="http://wesmckinney.com/blog/fast-and-easy-pivot-tables-in-pandas-0-5-0/" rel="noreferrer">Wes McKinney's blog</a>:</p>
  
  <pre><code>df.pivot_table(index=['id','num'], columns='q')
  
           v            
  q        a   b   d   z
  id num                
  1  10    2   4 NaN NaN
     12  NaN NaN   6 NaN
  2  13    8 NaN NaN NaN
     14  NaN  10 NaN NaN
  3  15  NaN NaN NaN  12
  </code></pre>
  
  <p>However, the format is not quite the same as what I want above.</p>