title: Python Pandas group by multiple columns, mean of another - no group by object
body: <p>I have some data that looks like this, and called 'test_df'</p>
  
  <pre><code>  ID  Year  Value  Value2
  0  A  2012      1       4
  1  A  2012      2       5
  2  A  2013      4       6
  3  A  2013      5       7
  4  B  2014      6       8
  5  B  2014      7       4
  6  B  2013      8       8
  </code></pre>
  
  <p>I want it to look like this:</p>
  
  <pre><code>ID Year  Value_avg  Value2_avg
  A  2012  1.5        4.5
  A  2013  4.5        6.5
  B  2013  8.0        8.0
  B  2014  6.5        6.0
  </code></pre>
  
  <p>However, when I try to group by multiple columns they end up as group by objects:</p>
  
  <pre><code>         Value_avg  Value2_avg
  ID Year
  A  2012        1.5         4.5
     2013        4.5         6.5
  B  2013        8.0         8.0
     2014        6.5         6.0
  </code></pre>
  
  <p>Here is the code I tried:</p>
  
  <pre><code>out_df = pd.DataFrame()
  out_df['Value_avg'] = test_df['Value'].groupby([test_df['ID'], test_df['Year']]).mean()
  out_df['Value2_avg'] = test_df['Value2'].groupby([test_df['ID'], test_df['Year']]).mean()
  </code></pre>
  
  <p>I tried adding:</p>
  
  <pre><code>out_df['Value_avg'] = test_df['Value'].groupby([test_df['ID'], 
  test_df['Year']], as_index=False).mean()
  </code></pre>
  
  <p>but got this error:</p>
  
  <pre><code>"TypeError: as_index=False only valid with DataFrame"
  </code></pre>