title: Pandas row function row iteration
body: <p>I have a dataframe and a maximum value:</p>
  
  <pre><code>max_factor = 20
  df = pd.DataFrame({'a':[1,1,1,2,2,2,3,3,3,3],'b':np.random.randn(10)})
  df
     a         b
  0  1 -0.424957
  1  1  1.893320
  2  1  0.187929
  3  2 -1.413340
  4  2  1.737371
  5  2  0.959317
  6  3 -0.554445
  7  3  0.100595
  8  3 -0.176009
  9  3  0.430475
  </code></pre>
  
  <p>I want to create another column 'c' and populate it with values that depend on values in 'a', 'b' and 'c'.</p>
  
  <p>For example: </p>
  
  <pre><code>if value(a) == 1 or value(a) == 2:
      value(c) = 0
  else:
      value(c) = value(b)/max_factor + value(c-1) 
  </code></pre>
  
  <p>I have tried multiple ways to do this but am struggling. Do I have to iterate through each row or is there a faster way to do this?</p>
  
  <p>EDIT: The actual function to generate the values in column 'c' is more complicated but this would be a great starting point.</p>