title: unmelting a pandas dataframe in Python?
body: <p>I melted a pandas dataframe for plotting use with ggplot (which often requires long form of dataframes), as follows:</p>
  
  <pre><code>test = pandas.melt(iris, id_vars=["Name"], value_vars=["SepalLength", "SepalWidth"])
  </code></pre>
  
  <p>This keeps the <code>Name</code> field of the iris dataset in the index, but transforms the columns <code>SepalLength</code> and <code>SepalWidth</code> into long form:</p>
  
  <pre><code>test.ix[0:10]
  Out:
             Name     variable  value
  0   Iris-setosa  SepalLength    5.1
  1   Iris-setosa  SepalLength    4.9
  2   Iris-setosa  SepalLength    4.7
  3   Iris-setosa  SepalLength    4.6
  4   Iris-setosa  SepalLength    5.0
  5   Iris-setosa  SepalLength    5.4
  6   Iris-setosa  SepalLength    4.6
  7   Iris-setosa  SepalLength    5.0
  8   Iris-setosa  SepalLength    4.4
  9   Iris-setosa  SepalLength    4.9
  10  Iris-setosa  SepalLength    5.4
  </code></pre>
  
  <p>How can I "unmelt" this dataframe back? I want the <code>Name</code> column to be kept, but the values of <code>variable</code> field to be transformed into separate columns. The <code>Name</code> field is not unique, so I don't think it can be used as an index. My impression was that <code>pivot</code> is the right function to do this but it is not right:</p>
  
  <pre><code>test.pivot(columns="variable", values="value")
  KeyError: u'no item named '
  </code></pre>
  
  <p>How could I do this? Also, could I unmelt dataframes where there are multiple columns that are in long form, i.e. multiple columns in <code>test</code> that are like the <code>variable</code> column above? It would mean that the <code>columns</code> will have to accept a list of columns, not a single value, it seems. thanks.</p>