title: How to categorize floating values in python using pandas library
body: <p>`    import pandas
      import numpy</p>
  
  <pre><code>#importing the dataset
  data=pandas.read_csv('gapminder.csv',low_memory=False)
  
  #setting variables to be worked with to numeric
  data['urbanrate']=data['urbanrate'].convert_objects(convert_numeric=True)
  data['femaleemployrate']=data['femaleemployrate'].convert_objects(convert_numeric=True)
  data['lifeexpectancy']=data['lifeexpectancy'].convert_objects(convert_numeric=True)
  
  print("Count for urbanrate")
  chk8=data['urbanrate'].value_counts(sort=False,dropna=False)
  print(chk8)
  
  sub1=data[['urbanrate','femaleemployrate','lifeexpectancy']]
  print (sub1.head(25))
  
  ===========================================================================
  def urban (row):
        if (row['urbanrate']&lt;25.0):
            return 1
        if (data[['urbanrate']&gt;=25.0 &amp; data['urbanrate']&lt;75.0]):
           return 2
        if (data['urbanrate']&gt;75.0):
           return 3
  sub1['urban']=sub1.apply(lambda row: urban (row),axis=1)
  print (sub1.head(25))
  ============================================================================`
  </code></pre>
  
  <p>I want to categorize all the values of <code>urbanrate</code> (which are all floating point numbers like <code>24.56</code>,<code>88.98</code>,<code>77.65</code>) into 3 different categories (one is values for <code>&lt;25</code>, another for <code>&gt;=25 and &lt;75</code> and last one for <code>&gt;=75</code>) and store those values in a new variable (say urban). How can I do this? I have given my code. I executed it and its giving me error as: </p>
  
  <blockquote>
    <p>TypeError: ('cannot compare a dtyped [float64] array with a scalar of type [bool]', 'occurred at index 1'))</p>
  </blockquote>
  
  <p>Please help me </p>