title: pandas group by function applied to a column
body: <p>In the Groupby documentation, I only see examples of grouping by functions applied to the index of axis 0 or to the labels of the columns. I see no examples discussing how to group by a label derived from applying a function to a column. I would think this would be done using <code>apply</code>. Is the example below the best way to do this?</p>
  
  <pre><code>df = pd.DataFrame({'name' : np.random.choice(['a','b','c','d','e'], 20), 
                 'num1': np.random.randint(low = 30, high=100, size=20),
                 'num2': np.random.randint(low = -3, high=9, size=20)})
  
  df.head()
  
    name  num1 num2
  0   d   34  7
  1   b   49  6
  2   a   51  -1
  3   d   79  8
  4   e   72  5
  
  def num1_greater_than_60(number_num1):
      if number_num1 &gt;= 60:
          return 'greater'
      else:
          return 'less'
  
  df.groupby(df['num1'].apply(num1_greater_than_60))
  </code></pre>