title: Filtering and selecting from pivot tables made with python pandas
body: <p>I'm struggling with hierarchical indexes in the Python <code>pandas</code> package.  Specifically I don't understand how to <strong>filter</strong> and <strong>compare</strong> data in rows after it has been pivoted.  </p>
  
  <p>Here is the example table from the documentation:  </p>
  
  <pre><code>import pandas as pd
  import numpy as np
  
  In [1027]: df = pd.DataFrame({'A' : ['one', 'one', 'two', 'three'] * 6,
                                'B' : ['A', 'B', 'C'] * 8,
                                'C' : ['foo', 'foo', 'foo', 'bar', 'bar', 'bar'] * 4,
                                'D' : np.random.randn(24),
                                'E' : np.random.randn(24)})
  
  In [1029]: pd.pivot_table(df, values='D', rows=['A', 'B'], cols=['C'])
  Out[1029]: 
      C             bar       foo
      A     B                    
      one   A -1.154627 -0.243234
            B -1.320253 -0.633158
            C  1.188862  0.377300
      three A -1.327977       NaN
            B       NaN -0.079051
            C -0.832506       NaN
      two   A       NaN -0.128534
            B  0.835120       NaN
            C       NaN  0.838040
  </code></pre>
  
  <p>I would like to analyze as follows:</p>
  
  <p>1) Filter this table on column attributes, for example selecting rows with negative <code>foo</code>:</p>
  
  <pre><code>    C             bar       foo
      A     B                    
      one   A -1.154627 -0.243234
            B -1.320253 -0.633158
      three B       NaN -0.079051
      two   A       NaN -0.128534
  </code></pre>
  
  <p>2) Compare the remaining <code>B</code> series values between the distinct <code>A</code> series groups?  I am not sure how to access this information: <code>{'one':['A','B'], 'two':['A'], 'three':['B']}</code> and determine which series <code>B</code> values are unique to each key, or seen in multiple key groups, etc</p>
  
  <p>Is there a way to do this directly within the pivot table structure, or do I need to convert this back in to a <code>pandas</code> <code>dataframe</code>?</p>
  
  <p><strong>Update:</strong>  I think this code is a step in the right direction.  It at least lets me access individual values within this table, but I am still hard-coding the series vales:</p>
  
  <pre><code>table = pivot_table(df, values='D', rows=['A', 'B'], cols=['C'])
  table.ix['one', 'A']
  </code></pre>