title: Pandas - Apply aggregation on filtered dataframe
body: <p>GroupBy a column and aggregate one of the columns on filtered values.</p>
  
  <p>Like in the given example below, I want to count the number of animals which are of gender 'male' for each of the 'kind' of animals</p>
  
  <pre><code>import pandas as pd
  df = pd.DataFrame({'kind': ['cat', 'dog', 'cat', 'dog'],
                  'height': [9.1, 6.0, 9.5, 34.0],
                  'gender': ['male', 'female', 'female', 'female']})
  df.groupby('kind').agg({'height': 'min', 'gender': lambda g: (g == 'male').count()})
  </code></pre>
  
  <p>Output that I get (which is wrong)</p>
  
  <pre><code>kind      height     gender
  cat       9.1        2
  dog       6.0        2
  </code></pre>
  
  <p>Expected output:</p>
  
  <pre><code>kind      height     gender
  cat       9.1        1
  dog       6.0        0
  </code></pre>