title: Pandas, groupby and count
body: <p>I have a dataframe say like this</p>
  
  <pre><code>&gt;&gt;&gt; df = pd.DataFrame({'user_id':['a','a','s','s','s'],
                      'session':[4,5,4,5,5],
                      'revenue':[-1,0,1,2,1]})
  
  &gt;&gt;&gt; df
     revenue  session user_id
  0       -1        4       a
  1        0        5       a
  2        1        4       s
  3        2        5       s
  4        1        5       s
  </code></pre>
  
  <p>And each value of session and revenue represents a kind of type, and I want to count the number of each kind say the number of <code>revenue=-1</code> and <code>session=4</code> of <code>user_id=a</code> is 1.</p>
  
  <p>And I found simple call <code>count()</code> function after <code>groupby()</code> can't output the result I want.</p>
  
  <pre><code>&gt;&gt;&gt; df.groupby('user_id').count()
           revenue  session
  user_id
  a              2        2
  s              3        3
  </code></pre>
  
  <p>How can I do that?</p>