title: Python Pandas subtract value of row from value of previous row
body: <p>I have the following,</p>
  
  <pre><code>import pandas as pd
  
  data = [['AAA','2019-01-01', 10], ['AAA','2019-01-02', 21],
          ['AAA','2019-02-01', 30], ['AAA','2019-02-02', 45],
          ['BBB','2019-01-01', 50], ['BBB','2019-01-02', 60],
          ['BBB','2019-02-01', 70],['BBB','2019-02-02', 80]]
  
  dfx = pd.DataFrame(data, columns = ['NAME', 'TIMESTAMP','VALUE'])
  
    NAME   TIMESTAMP  VALUE
  0  AAA  2019-01-01     10
  1  AAA  2019-01-02     21
  2  AAA  2019-02-01     30
  3  AAA  2019-02-02     45
  4  BBB  2019-01-01     50
  5  BBB  2019-01-02     60
  6  BBB  2019-02-01     70
  7  BBB  2019-02-02     80
  </code></pre>
  
  <p>I want to generate a new column which lists the difference of the VALUE column for the current row from the previous row.</p>
  
  <p>So the output would look somewhat like this,</p>
  
  <pre><code>  NAME   TIMESTAMP  VALUE  DIFF
  0  AAA  2019-01-01     10  
  1  AAA  2019-01-02     21  11
  2  AAA  2019-02-01     30   9
  3  AAA  2019-02-02     45  15
  4  BBB  2019-01-01     50
  5  BBB  2019-01-02     60  10
  6  BBB  2019-02-01     70  10
  7  BBB  2019-02-02     80  10
  </code></pre>
  
  <p>Regards.</p>