title: Group by and sum the previous element
body: <p>Good Morning, I have the following df:</p>
  
  <pre><code>print(df)
  
  Date          cod_id      Sales    Initial_stock  
  01/01/2017      1           5          5                
  01/01/2017      2           4          8                
  02/01/2017      1           1          5                 
  ...
  </code></pre>
  
  <p>Since there are a few mistakes in the real dataset, regarding "Initial_stock", I would like to create a new column, for the different <em>cod_id</em>s(= products), as: </p>
  
  <p>Initial stock in the previous row of that <em>cod_id</em> + current value of initial stock - Sales;  so:</p>
  
  <pre><code>print(df_final)
  
  Date          cod_id      Sales    Initial_stock  new  
  01/01/2017      1           5          5           0          
  01/01/2017      2           4          8           4                      
  02/01/2017      1           1          5           4  
  ...
  </code></pre>
  
  <p>In which the last value equals to 4 of <em>"cod_id 1"</em> is computed as: 0 + 5 - 1 = 4</p>