title: How to filter and groupby in python
body: <p>I have a data set (made up the below as an example) and I am trying to group and filter at the same time. I want to groupby the occupation and then filter the Sex for just males. I am also working in pandas.</p>
  
  <pre><code>Occupation             Age    Sex
  Accountant              23     Female
  Doctor                  33     Male
  Accountant              43     Male
  Doctor                  28     Female
  </code></pre>
  
  <p>I'd like the final result to look something like this:</p>
  
  <pre><code>Occupation    Sex
  Accountant     1
  Doctor         1
  </code></pre>
  
  <p>So far I have come up with the below but it doesn't filter males for sex</p>
  
  <pre><code>data.groupby(['occupation'])[['sex']].count()    
  </code></pre>
  
  <p>Thank you.</p>