title: How to make a pandas crosstab with percentages?
body: <p>Given a dataframe with different categorical variables, how do I return a cross-tabulation with percentages instead of frequencies?</p>
  
  <pre><code>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)})
  
  
  pd.crosstab(df.A,df.B)
  
  
  B       A    B    C
  A               
  one     4    4    4
  three   2    2    2
  two     2    2    2
  </code></pre>
  
  <p>Using the margins option in crosstab to compute row and column totals gets us close enough to think that it should be possible using an aggfunc or groupby, but my meager brain can't think it through.</p>
  
  <pre><code>B       A     B    C
  A               
  one     .33  .33  .33
  three   .33  .33  .33
  two     .33  .33  .33
  </code></pre>