title: Speeding up an iloc solution within a pandas dataframe
body: <p>I have the following <code>DataFrame</code>:</p>
  
  <pre><code>dates = pd.date_range('20150101', periods=4)
  df = pd.DataFrame({'A' : [5,10,3,4]}, index = dates)
  
  df.loc[:,'B'] = 0
  df.loc[:,'C'] = 0
  df.iloc[0,1]  = 10
  df.iloc[0,2]  = 3
  
  print df
  
  Out[69]:
  
               A   B  C
  2015-01-01   5  10  3
  2015-01-02  10   0  0
  2015-01-03   3   0  0
  2015-01-04   4   0  0
  </code></pre>
  
  <p>I want to implement the following logic for the columns <code>B</code> and <code>C</code>:</p>
  
  <ul>
  <li><code>B(k+1) = B(k) - A(k+1)</code></li>
  <li><code>C(k+1) = B(k) + A(k+1)</code></li>
  </ul>
  
  <p>I can do this using the following code:</p>
  
  <pre><code>for i in range (1, df.shape[0]): 
          df.iloc[i,1] = df.iloc[i-1,1] - df.iloc[i,0] 
          df.iloc[i,2] = df.iloc[i-1,1] + df.iloc[i,0] 
  print df
  </code></pre>
  
  <p>This gives:</p>
  
  <pre><code>             A   B   C
  2015-01-01   5  10   3
  2015-01-02  10   0  20
  2015-01-03   3  -3   3
  2015-01-04   4  -7   1
  </code></pre>
  
  <p>Which is the answer I'm looking for. The problem is when I apply this to a <code>DataFrame</code> with a large dataset it runs slow. Very slow. Is there a better way of achieving this? </p>