title: How to do a conditional count after groupby on a Pandas Dataframe?
body: <p>I have the following dataframe:</p>
  
  <pre class="lang-py prettyprint-override"><code>   key1  key2
  0    a   one
  1    a   two
  2    b   one
  3    b   two
  4    a   one
  5    c   two
  </code></pre>
  
  <p>Now, I want to group the dataframe by the <code>key1</code> and count the column <code>key2</code> with the value <code>"one"</code> to get this result:</p>
  
  <pre class="lang-py prettyprint-override"><code>   key1  
  0    a   2
  1    b   1
  2    c   0
  </code></pre>
  
  
  
  <p>I just get the usual count with:</p>
  
  <pre class="lang-py prettyprint-override"><code>df.groupby(['key1']).size()
  </code></pre>
  
  <p>But I don't know how to insert the condition.</p>
  
  <p>I tried things like this:</p>
  
  <pre class="lang-py prettyprint-override"><code>df.groupby(['key1']).apply(df[df['key2'] == 'one'])
  </code></pre>
  
  <p>But I can't get any further.  How can I do this?</p>