title: Python Pandas: Passing arguments to a function in agg()
body: <p>I am trying to reduce data in a pandas dataframe by using different kind of functions and argument values. However, I did not manage to change the default arguments in the aggregation functions. Here is an example:</p>
  
  <pre><code>&gt;&gt;&gt; df = pd.DataFrame({'x': [1,np.nan,2,1],
  ...                    'y': ['a','a','b','b']})
  &gt;&gt;&gt; df
       x  y
  0  1.0  a
  1  NaN  a
  2  2.0  b
  3  1.0  b
  </code></pre>
  
  <p>Here is an aggregation function, for which I would like to test different values of <code>b</code>:</p>
  
  <pre><code>&gt;&gt;&gt; def translate_mean(x, b=10):
  ...   y = [elem + b for elem in x]
  ...   return np.mean(y)
  </code></pre>
  
  <p>In the following code, I can use this function with the default <code>b</code> value, but I would like to pass other values:</p>
  
  <pre><code>&gt;&gt;&gt; df.groupby('y').agg(translate_mean)
        x
  y
  a   NaN
  b  11.5
  </code></pre>
  
  <p>Any ideas?</p>