title: Subtracting values of a row for a specific column based on a specific condition in python dataframe
body: <p>My data looks like below :</p>
  
  <pre><code>Customer  Product Date       Amount Paid
  C1        P1      5/10/2011  100
  C1        P1      5/18/2015  200
  C1        P1      6/17/2019  300
  C2        P2      4/18/2019  50
  </code></pre>
  
  <p>I want for each customer and product , difference between the last two amount paid based on the date,difference between 1st and last amount paid. and difference between and maximum and minimum amount paid. </p>
  
  <p>For customers who have only one transaction , these becomes 0. So output should look like : </p>
  
  <pre><code>Customer Product   Diff_first_last    Diff_last_two   Diff_min_max
  C1       P1        200                100             200
  C2       P2        0                  0                0
  </code></pre>