title: Pandas crosstab on multiindex
body: <p>Hi I am trying to get Crosstab from a multi index variable "df" :</p>
  
  <p>df.tail()</p>
  
  <pre><code>code    X1  X2  X3
  pays    USA USA USA
  desc    phase   phase   phase
  2020-01-01  a   a   a
  2020-02-01  b   c   d
  2020-03-01  a   a   b
  2020-04-01  c   a   a
  2020-05-01  d   a   d
  </code></pre>
  
  <p>I would like to get something like : </p>
  
  <pre><code>             X1                X2           X3
         a   b   c   d       a  b  c  d    a  b  c  d
  
      a
  X1  b 
      c 
      d                          
      a
  X2  b 
      c
      d
      a
  X3  b
      c 
      d 
  </code></pre>
  
  <p>where in each cell I get the number / percentage of Xi, Xj value of (a,b,c,d)</p>
  
  <p>I tried : </p>
  
  <pre><code>pd.crosstab(index = df, columns = df) 
  </code></pre>
  
  <p>but I get an error message :</p>
  
  <pre><code>ValueError: Shape of passed values is (3, 2), indices imply (605, 2)
  </code></pre>
  
  <p>Thanks for your help </p>