title: Mathematical calculation using for loop in a dataframe
body: <p>I have a dataframe which looks like this</p>
  <pre><code>df= 
  
      Time                  x          y
  0   2018-09-13 01:17:00  5.0        0.0
  1   2018-09-13 02:17:00  9.0        0.0
  2   2018-09-13 03:17:00  2.0        1.0
  3   2018-09-13 04:17:00  1.0        0.0
  </code></pre>
  <p>.......
  I want to iterate through this whole dataframe and calculate a new variable z.
  The value of z would be <code>z= z[prev]+ x-y</code></p>
  <p>for example,  the final output would be</p>
  <pre><code>Time                         z
  0   2018-09-13 01:17:00      5    #[0+5-0]
  1   2018-09-13 02:17:00      14   #[5+9-0]
  2   2018-09-13 03:17:00      15   #[14+2-1]
  3   2018-09-13 04:17:00      16   #[15+1-0]
  </code></pre>
  <p>.....</p>
  <p>I am finding it difficult to iterate over the time series data.</p>
  <p>I have tried the following but it is not working.</p>
  <pre><code>for i,row in df.iterrows():
      z=0
      row['z']=row['z']+row['x']-row['y']
  
  print[z]
  </code></pre>