title: How to combine multiple groupby aggregations with calculated column?
body: <p>Disclaimer: I'm a doctor with no formal training tasked with building a report that looks at how many patients are meeting therapy goals, and I need to break this down by facility and clinic. I can get the denominator (total cases by facility and clinic) and the numerator (total cases meeting therapy goals), but I can't figure out how to display both of those in a groupby along with a column showing the percent meeting goals (num / denom).</p>
  
  <p>Sample dataframe:</p>
  
  <pre><code>import pandas as pd
  
  df = pd.DataFrame([[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15],
                     ['anxiety','PTSD','PTSD','anxiety','PTSD','depression','anxiety','anxiety','PTSD','anxiety','anxiety','anxiety','depression','depression','PTSD'],
                     [False,False,False,True,True,False,True,False,False,False,False,False,False,False,False],
                     ['120C','120C','120C','120C','120C','120C','120C','120C','120C','120C','375C','375C','375C','375C','375C'],
                     ['BH-PSYL','BH-PSYL','BH-YUKON','BH-DENALI','BH-YUKON','BH-DENALI','BH-CFS','BH-CFS','BH-CFS','BH-CFS','BH-HTHPSY','BH-HTHPSY','BH-BSS','BH-HTHPSY','BH-BSS']]).T
  df.columns = ['Patient ID','DX Category','Met Goal','Facility','Clinic']
  </code></pre>
  
  <p>This gives the denominator:</p>
  
  <p><code>df.groupby(['Facility', 'Clinic']).count()[['Met Goal']]</code></p>
  
  <p>This gives the numerator:</p>
  
  <p><code>df[df['Met Goal'] == True].groupby(['Facility', 'Clinic']).count()[['Met Goal']]</code></p>
  
  <p>The final result should show (made-up numbers):</p>
  
  <pre><code>Facility | Clinic   | Met Goal | Cases | Percent
  120C
           | BH-PSYL  |     1    |   4   |  25%
           | BH-YUKON |     2    |   6   |  33%
  375C     
           | BH-CFS   |     0    |   1   |   0%
  
  </code></pre>
  
  <p>Any help is appreciated!</p>