title: Python: count values within defined intervals
body: <p>I import data from a CSV which looks like this:</p>
  
  <pre><code>3.13
  3.51
  3.51
  4.01
  2.13
  1.13
  1.13
  1.13
  1.63
  1.88
  </code></pre>
  
  <p>What I would like to do now is to <strong>COUNT</strong> the values within those intervals:
  0-1, 1-2, 2-3, >3</p>
  
  <p>So the result would be</p>
  
  <pre><code>0-1: 0
  1-2: 5
  2-3: 1
  &gt;3: 4
  </code></pre>
  
  <p>Apart from this main task I would like to calculate the outcome into percent of total numbers (e.g. 0-1: 0%, 1-2: 50%,...)</p>
  
  <p>I am quite new to Python so I got stuck in my attemps solving this thing. Maybe there is a predefined function for solving this I don't know of?</p>
  
  <p>Thanks a lot for your help!!!</p>
  
  <p><strong>+++ UPDATE: +++</strong></p>
  
  <p>Thanks for all the replies.
  I have testes a bunch of them but I kind of doing something wrong with reading the CSV-File I guess. Refering to the code snippets using a,b,c,d for the differnt intervalls these variables always stay '0' for me.</p>
  
  <p>Here is my actual code:</p>
  
  <pre><code>import csv
  
  a=b=c=0
  with open('winter.csv', 'rb') as csvfile:
      spamreader = csv.reader(csvfile, delimiter=',')
      for row in spamreader:
          if row in range(0,1):
              a += 1
          elif row in range (1,2):
              b += 1
  
  print a,b
  </code></pre>
  
  <p>I also converted all values in the CSV to Integers without success. In the CSV there is just one single column.
  Any ideas what I am doing wrong???</p>