title: Counting column values based on values in other columns for Pandas dataframes
body: <p>I'm trying to count the number of each category of storm for each unique <code>x</code> and <code>y</code> combination. For example. My dataframe looks like:</p>
  
  <pre><code>x   y  year  Category
  1   1  1988     3
  2   1  1977     1
  2   1  1999     2
  3   2  1990     4
  </code></pre>
  
  <p>I want to create a dataframe that looks like:</p>
  
  <pre><code>x   y   Category 1   Category 2   Category 3  Category 4
  1   1        0           0            1           0
  2   1        1           1            0           0
  3   2        0           0            0           1
  </code></pre>
  
  <p>I have tried various combinations of <code>.groupby()</code> and <code>.count()</code>, but I am still not getting the desired result. The closet thing I could get is:</p>
  
  <pre><code>df[['x','y','Category']].groupby(['Category']).count()
  </code></pre>
  
  <p>However, the result counts for all <code>x</code> and <code>y</code>, not the unique pairs:</p>
  
  <pre><code>Cat       x           y     
  1       3773         3773
  2       1230         1230
  3       604          604
  4       266          266
  5       50           50
  NA      27620        27620
  TS      16884        16884
  </code></pre>
  
  <p>Does anyone know how to do a count operation on one column based on the uniqueness of two other columns in a dataframe?</p>