title: How to use two different functions within crosstab/pivot_table in pandas?
body: <p>Using pandas, is it possible to compute a single cross-tabulation (or pivot table) containing values calculated from two different functions?</p>
  
  <pre><code>import pandas as pd
  import numpy as np
  
  c1 = np.repeat(['a','b'], [50, 50], axis=0)
  c2 = list('xy'*50)
  c3 = np.repeat(['G1','G2'], [50, 50], axis=0)
  np.random.shuffle(c3)
  c4=np.repeat([1,2], [50,50],axis=0)
  np.random.shuffle(c4)
  val = np.random.rand(100)
  
  df = pd.DataFrame({'c1':c1, 'c2':c2, 'c3':c3, 'c4':c4, 'val':val})
  
  frequencyTable = pd.crosstab([df.c1,df.c2],[df.c3,df.c4])
  meanVal = pd.crosstab([df.c1,df.c2],[df.c3,df.c4],values=df.val,aggfunc=np.mean)
  </code></pre>
  
  <p>So, both the rows and the columns are the same in both tables, but what I'd really like is a table with both frequencies and mean values:</p>
  
  <pre><code>c3           G1                       G2          
  c4     1              2              1              2
  c1 c2  freq val       freq val       freq val       freq val         
  a  x   6    0.624931  5    0.582268  8    0.528231  6    0.362804
     y   7    0.493890  8    0.465741  3    0.613126  7    0.312894
  b  x   9    0.488255  5    0.804015  6    0.722640  5    0.369480
     y   6    0.462653  4    0.506791  5    0.583695  10   0.517954
  </code></pre>