title: iterate through 1 column, adding to new column
body: <p>Ive got a dataframe X, with 3 columns- accel, decel and stop.
  There are 111110 rows.</p>
  
  <p>I would like to iterate through the values in the accel column, so that if the value obeys a certain condition, a new value is created and saved in 'r' for each variable in the accel column of X.
  I have the following code-</p>
  
  <pre><code>r=[]
  pos=0
  while pos&lt;=111110:
  for i in X['accel']:
      if i&lt;10:
          r.append(1)
      elif 10&lt;=i&gt;=20:
          r.append(2)
      elif 20&lt;=i&gt;=30:
          r.append(3)
      elif 30&lt;=i&gt;=40:
          r.append(4)
      elif i&gt;40:
          r.append(5)
          pos+=1
  
  frames = [r,X]
  result = pd.concat(frames)
  </code></pre>
  
  <p>however when this runs, i only get </p>
  
  <pre><code>for i in X['accel']:
  IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices
  </code></pre>
  
  <p>how can i make the code run through the full column of the dataframe and then print values of r as an additional column to the X dataframe?
  Thanks</p>