title: Reshaping data in Pandas (multi index in the columns, maybe in the rows too)
body: <p>I have a dataframe with 6 columns.  The first 5 uniquely identify an observation.  The 6th is the value of that observation.  I would like to pivot the data so that, of the 5 identifying columns, 3 become a hierarchical row index while the other 2 become a hierarchical column index.</p>
  
  <p>Specifically, with the following setup:</p>
  
  <pre><code>import numpy as np
  import pandas as pd
  from itertools import product
  
  np.random.seed(1)
  
  team_names = ['Yankees', 'Mets', 'Dodgers']
  jersey_numbers = [35, 71, 84]
  game_numbers = [1, 2]
  observer_names = ['Bill', 'John']
  observation_types = ['Speed', 'Strength']
  
  row_indices = list(product(team_names, jersey_numbers, game_numbers, observer_names, observation_types))
  observation_values = np.random.randn(len(row_indices))
  
  tns, jns, gns, ons, ots = zip(*row_indices)
  
  data = pd.DataFrame({'team': tns, 'jersey': jns, 'game': gns, 'observer': ons, 'obstype': ots, 'value': observation_values})
  </code></pre>
  
  <p>I would like to reshape the data so that the rows are <code>team</code>, <code>jersey</code>, and <code>game</code> while the columns are <code>observer</code> and <code>obstype</code>.  The following seems to get the job done:</p>
  
  <pre><code>pd.pivot_table(data, values='value', cols=['observer', 'obstype'], rows=['team', 'jersey', 'game'])
  </code></pre>
  
  <p>Are there any other ways to do this kind of thing?  I had initially tried making all the columns except for <code>value</code> into an index and then using <code>unstack(['observer', 'obstype'])</code>.  But this gave me an unnecessary extra level in my column hierarchy: an unnamed level whose only entry was <code>value</code> (i.e. the name of the column whose data I actually wanted in the guts of my table).</p>
  
  <p>What's the right way to handle a situation like this?  Is it just to use <code>pivot_table</code> as I did above?  Or is there a better general strategy?</p>