title: Pandas: Moving from table to matrix layout
body: <p>I have a DataFrame that looks like (it's a set of combinations):</p>
  
  <pre><code>   A  B  C  
  a  1  1  3  
  b  1  2  4  
  c  2  1  5  
  d  2  2  6  
  </code></pre>
  
  <p>Which I would like to transform into a matrix where the new columns and indexes are unique values of two of the columns (<code>A</code> and <code>B</code>) and the cells are the join between these two unique values from a third column (<code>C</code>).</p>
  
  <p>With <code>A</code> as the index, <code>B</code> as the columns and <code>C</code> as the cell values I would have something like:</p>
  
  <pre><code>   B
  A  1 2
  1  3 4  
  2  5 6
  </code></pre>
  
  <p>To generate this new 'matrix' DataFrame I iteratively filter the original DF by the unique values in columns <code>A</code>, then get the <code>C</code> column as a Series, like:</p>
  
  <pre><code>for ind in unique_indexes: # made by using .drop_duplicates on the column
      rows = original_table[(original_table['A'] == ind)] 
      new_series = rows['C']
  </code></pre>
  
  <p>I'm then trying to glue all of these Series together as rows in a new DataFrame, but can't get any of them to either <code>append</code> or <code>concat</code> into the new DataFrame (following both the <a href="http://pandas.pydata.org/pandas-docs/stable/merging.html" rel="nofollow noreferrer">docs</a> or <a href="https://stackoverflow.com/questions/10715965/add-one-row-in-a-pandas-dataframe">similar questions on SO</a>), e.g. </p>
  
  <pre><code># with suitable placement in 'for' loop
  df = DataFrame()
  df.append(new_series)
  
  &gt;&gt;&gt; print df
  Empty DataFrame
  </code></pre>
  
  <p>Is there a) a better way of doing this transformation, or b) a step that I'm missing in appending series to a DataFrame? </p>
  
  <p>Cheers</p>