title: Pandas combine two group by's, filter and merge the groups(counts)
body: <p>I have a dataframe that I need to combine two different groupbys with one of them filtered.</p>
  
  <pre><code> ID     EVENT      SUCCESS
   1       PUT          Y
   2       POST         Y
   2       PUT          N
   1       DELETE       Y 
  </code></pre>
  
  <p>This table below is how I would like the data to look like. Firstly grouping the 'EVENT' counts, the second is to count the amount of Successes ('Y') per ID</p>
  
  <pre><code>ID  PUT   POST  DELETE SUCCESS
   1   1     0       1      2
   2   1     1       0      1
  </code></pre>
  
  <p>I've tried a few techniques and the closet I've found is two separate methods which yield the following</p>
  
  <p><code>group_df = df.groupby(['ID', 'EVENT'])
   count_group_df  = group_df.size().unstack()</code></p>
  
  <p>Which yields the following for the 'EVENT' counts</p>
  
  <pre><code>ID  PUT   POST  DELETE
   1   1     0       1      
   2   1     1       0      
  </code></pre>
  
  <p>For the Successes with filters, i dont know whether I can join this to the first set on 'ID'</p>
  
  <pre><code> df_success = df.loc[df['SUCCESS'] == 'Y', ['ID', 'SUCCESS']]
   count_group_df_2 = df_success.groupby(['ID', 'SUCCESS'])
  
  
  ID  SUCCESS
  1      2
  2      1
  </code></pre>
  
  <p>I need to combine these somehow?</p>
  
  <p>Additionally I'd also like to merge the counts two of the 'EVENT''s for example PUT's and POST's into one column.</p>