title: pandas, melt, unmelt preserve index
body: <p>I've got a table of clients (coper) and asset allocation (asset)</p>
  
  <pre><code>A = [[1,2],[3,4],[5,6]]
  idx = ['coper1','coper2','coper3']
  cols = ['asset1','asset2']
  
  df = pd.DataFrame(A,index = idx, columns = cols)
  </code></pre>
  
  <p>so my data look like</p>
  
  <pre><code>        asset1  asset2
  coper1       1       2
  coper2       3       4
  coper3       5       6
  </code></pre>
  
  <p>and I want to run them through a linear optimization (i've got constraints- somtehing like <code>sum of all of asset_i &lt;= amount_on_hand_i</code> and <code>sum of coper_j = price_j</code>)</p>
  
  <p>so I have to turn this 2D matrix into a 1D vector.  Which is easy with melt</p>
  
  <pre><code>df2 = pd.melt(df,value_vars=['asset1','asset2'])
  </code></pre>
  
  <p>But now, when I try to unmelt it, I get a 6-row array with lots of blanks!</p>
  
  <pre><code>df2.pivot(columns = 'variable', values = 'value')
  
  
  variable  asset1  asset2
  0            1.0     NaN
  1            3.0     NaN
  2            5.0     NaN
  3            NaN     2.0
  4            NaN     4.0
  5            NaN     6.0
  </code></pre>
  
  <p>Is there any way to preserve the 'coper' part of my indexing while using melt?</p>