title: Pandas groupby and custom agg lambda function
body: <p>I have a data frame and I want to aggregate a custom aggregation function.</p>
  
  <p>Right now I have it like a predefined function, but I want to call it as a lambda function. Notice that the predefined function has a parameter that can be change.</p>
  
  <pre class="lang-py prettyprint-override"><code>from sklearn.datasets import load_boston
  import pandas as pd
  import numpy as np
  bunch = load_boston()
  
  y = bunch.target
  X = pd.DataFrame(bunch.data, columns=bunch.feature_names)
  
  def percentile_func(y,PERCENTILE=50):
      return np.percentile(y,PERCENTILE)
  
  X.groupby('CHAS')['CRIM'].agg([percentile_func,'sum', 'count'])
  </code></pre>