title: Frequency count using itertools.groupby() with recarray
body: <p>The code goes something like this:</p>
  
  <pre><code>&gt;&gt;&gt;data = pd.DataFrame({'P': ['p1', 'p1', 'p2'],
                          'Q': ['q1', 'q2', 'q1'],
                          'R': ['r1', 'r1', 'r2']})
  
  &gt;&gt;&gt;data
  
    P  Q  R
  0 p1 q1 r1
  1 p1 q2 r1
  2 p2 q1 r2
  
  &gt;&gt;&gt;data.groupby(['R'] + ['P','Q']).size().unstack(['P','Q'])
  </code></pre>
  
  <p>After reindexing and fillna(0) it gives the following result:</p>
  
  <pre><code>P  p1      p2
  Q  q1  q2  q1  q2
  R
  r1  1   1   0   0
  r2  0   0   1   0
  </code></pre>
  
  <p>I wanted to do the same with recarray so I imported itertools and tried the following:</p>
  
  <pre><code>&gt;&gt;&gt;data = np.array([('p1', 'p1', 'p2'), ('q1', 'q2', 'q1'), ('r1', 'r1', 'r2')], 
                       dtype=[('P',object),('Q',object),('R',object)]).view(np.recarray)
  
  &gt;&gt;&gt;groupby(data,key = (['R']+['P','Q'])).size().unstack(['P','Q'])
  </code></pre>
  
  <p>It doesn't work. How do I achieve a similar result without using pandas?</p>