title: Age group categorization
body: <p>I have dataframe, in that I have age column.I want to apply user defined function, so it arrange age in bins. I have following function trying to apply over columns but i am getting error. Name of the column is 'age'</p>
  
  <pre><code>def ageGroup(x):
      if (data_drop_row['age'] &gt; 0) &amp; (data_drop_row['age'] &lt;= 10):
          return '1'
      elif (data_drop_row['age'] &gt; 10) &amp; (data_drop_row['age'] &lt;= 20):
          return '2'
      elif( data_drop_row['age']) &gt; 20 &amp; (data_drop_row['age'] &lt;= 30):
          return '3'
      elif (data_drop_row['age'] &gt; 30) &amp; (data_drop_row['age'] &lt;= 40):
          return '4'
      elif (data_drop_row['age'] &gt; 40) &amp; (data_drop_row['age'] &lt;= 50):
          return  '5'
      elif (data_drop_row['age'] &gt; 50) &amp; (data_drop_row['age'] &lt;= 60):
          return  '6'
      elif (data_drop_row['age'] &gt; 60) &amp; (data_drop_row['age'] &lt;= 70):
          return '7'
      elif (data_drop_row['age'] &gt; 70) &amp; (data_drop_row['age'] &lt;= 80):
          return '8'
      elif (data_drop_row['age'] &gt; 80) &amp; (data_drop_row['age'] &lt;= 90):
          return '9'
      else:
          return '10'
  
  data_drop_row['age_cat'] = data_drop_row['age'].apply(ageGroup)
  </code></pre>
  
  <hr>
  
  <pre><code>ValueError                                Traceback (most recent call last)
  &lt;ipython-input-66-bc9d37e55aa8&gt; in &lt;module&gt;
  ----&gt; 1 data_drop_row['age_cat'] = data_drop_row['age'].apply(ageGroup)
  
  ~\Anaconda3\lib\site-packages\pandas\core\series.py in apply(self, func, convert_dtype, args, **kwds)
     3589             else:
     3590                 values = self.astype(object).values
  -&gt; 3591                 mapped = lib.map_infer(values, f, convert=convert_dtype)
     3592 
     3593         if len(mapped) and isinstance(mapped[0], Series):
  
  pandas/_libs/lib.pyx in pandas._libs.lib.map_infer()
  
  &lt;ipython-input-65-c5584bcb554d&gt; in ageGroup(x)
        1 def ageGroup(x):
  ----&gt; 2     if (data_drop_row['age'] &gt; 0) &amp; (data_drop_row['age'] &lt;= 10):
        3         return '1'
        4     elif (data_drop_row['age'] &gt; 10) &amp; (data_drop_row['age'] &lt;= 20):
        5         return '2'
  
  ~\Anaconda3\lib\site-packages\pandas\core\generic.py in __nonzero__(self)
     1476         raise ValueError("The truth value of a {0} is ambiguous. "
     1477                          "Use a.empty, a.bool(), a.item(), a.any() or a.all()."
  -&gt; 1478                          .format(self.__class__.__name__))
     1479 
     1480     __bool__ = __nonzero__
  
  ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
  </code></pre>
  
  <p>can someone help on this</p>