title: Pivot Tables or Group By for Pandas?
body: <p>I have a hopefully straightforward question that has been giving me a lot of difficulty for the last 3 hours.  It should be easy.  </p>
  
  <p>Here's the challenge.</p>
  
  <p>I have a pandas dataframe:</p>
  
  <pre><code>+--------------------------+
  |     Col 'X'    Col 'Y'  |
  +--------------------------+
  |     class 1      cat 1  |
  |     class 2      cat 1  |
  |     class 3      cat 2  |
  |     class 2      cat 3  |
  +--------------------------+
  </code></pre>
  
  <p>What I am looking to transform the dataframe into:</p>
  
  <pre><code>+------------------------------------------+
  |                  cat 1    cat 2    cat 3 |
  +------------------------------------------+
  |     class 1         1        0        0  |
  |     class 2         1        0        1  |
  |     class 3         0        1        0  |
  +------------------------------------------+
  </code></pre>
  
  <p>Where the values are value counts.  Anybody have any insight?  Thanks!</p>