title: Multiple Groupings on Pandas DataFrame
body: <p>Forgive any bad wording as I'm rather new to Pandas. I've done a fair amount of Googling but can't quite figure out the keywords I need to get the answer I'm looking for. I have some rather simple data containing counts of a certain flag grouped by IDs and dates, similar to the below:</p>
  
  <pre><code>id        date          flag   count
  -------------------------------------
  CAZ1      02/03/2012    Y      12
  CAZ1      02/03/2012    N      7
  CAZ2      03/03/2012    Y      6
  CAZ2      03/03/2012    N      2
  CRI2      02/03/2012    Y      14
  CRI2      02/03/2012    G      5
  LMU3      01/12/2013    G      7
  LMU4      02/12/2013    G      4
  LMU5      01/12/2014    G      3
  LMU6      01/12/2014    G      2
  LMU7      05/12/2014    G      2
  EUR4      01/16/2014    N      3
  </code></pre>
  
  <p>What I'm looking to do is group the IDs by certain flag <strong>combinations</strong>, sum their counts, and then get means for these per year. Resulting data should look something like:</p>
  
  <pre><code>        2012        2013        2014        Mean Calculations:
  --------------------------------------
  Y,N |   6.75        NaN         NaN         (((12+7)/2)+((6+2)/2))/2
  --------------------------------------
  Y,G |   9.5         NaN         NaN         (14+5)/2         
  --------------------------------------
  G   |   NaN         5.5         2.33        (7+4)/2, (3+2+2)/3
  --------------------------------------
  N   |   NaN         NaN         3           (3)
  </code></pre>
  
  <p>Not sure if this makes sense. I think I need to perform multiple GroupBys at the same time, with the option to define the different criteria for each of the different groupings.</p>
  
  <p>Happy to clarify further if needed. My initial attempts at coding this have been filled with errors so I don't think there's much benefit in posting progress so far. In fact, I just tried to write something and it seemed more misleading than helpful. Sorry, >_&lt;.</p>