title: Python Pandas add column to multi-index GroupBy DataFrame
body: <p>I am trying to add a column to a Pandas GroupBy DataFrame with a multi-index. The column is the difference between the max and mean value of a common key after grouping.</p>
  
  <p>Here is the input DataFrame:</p>
  
  <pre><code>   Main  Reads  Test  Subgroup
  0     1      5    54         1
  1     2      2    55         1
  2     1     10    56         2
  3     2     20    57         3
  4     1      7    58         3
  </code></pre>
  
  <p>Here is the code:</p>
  
  <pre><code>import numpy as np
  import pandas as pd
  
  df = pd.DataFrame({'Main': [1, 2, 1, 2, 1], 'Reads': [5, 2, 10, 20, 7],\
                     'Test':range(54,59), 'Subgroup':[1,1,2,3,3]})
  
  result = df.groupby(['Main','Subgroup']).agg({'Reads':[np.max,np.mean]})
  </code></pre>
  
  <p>Here is the variable <code>result</code> before perform the calculation of <code>diff</code>:</p>
  
  <pre><code>              Reads     
                 amax mean
  Main Subgroup           
  1    1            5    5
       2           10   10
       3            7    7
  2    1            2    2
       3           20   20
  </code></pre>
  
  <p>Next, I calculate the <code>diff</code> column with:</p>
  
  <pre><code>result['Reads']['diff'] = result['Reads']['amax'] - result['Reads']['mean']
  </code></pre>
  
  <p>but here is the output:</p>
  
  <pre><code>/home/userd/test.py:9: SettingWithCopyWarning: 
  A value is trying to be set on a copy of a slice from a DataFrame.
  Try using .loc[row_indexer,col_indexer] = value instead
  
  See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/
  ...stable/indexing.html#indexing-view-versus-copy
  ...result['Reads']['diff'] = result['Reads']['amax'] - result['Reads']['mean']
  </code></pre>
  
  <p>I would like the <code>diff</code> column to be at the same level a <code>amax</code> and <code>mean</code>.</p>
  
  <p>Is there a way to add a column to the innermost (bottom) column index of a multi-index <code>GroupBy()</code> object in Pandas?</p>