title: python: iterate in groupby pandas, add new columns based on previous value
body: <p>My dataframe is:</p>
  <pre><code>id            beg                       end                 
  client1     2021-10-19 16:01:01       2021-10-21 08:19:17                
  client1     2021-10-21 10:41:53       2021-10-24 07:53:57  
  client3     2021-10-21 09:00:00       2021-10-21 10:00:00       
  client3     2021-10-21 10:00:00       2021-10-22 14:00:00             
  client2     2021-10-21 10:00:00       2021-10-21 14:00:00
  </code></pre>
  <p>I want to add columns based on previous value of column by <code>id</code> as shown below.</p>
  <p>If the client appears more than once then I want to create new columns on the second appearance of this client...</p>
  <ul>
  <li><code>col1</code>  that takes the previous <code>end</code></li>
  <li><code>col2</code> that takes the current <code>beg</code> of this row (in this example, for client1 and client3).</li>
  </ul>
  <p>...else put nothing in <code>col1</code>, <code>col2</code></p>
  <p>Expected output:</p>
  <pre><code>  id                 beg                   end                col1                col2
  client1     2021-10-19 16:01:01    2021-10-21 08:19:17      -                      -          
  client1     2021-10-21 10:41:53    2021-10-24 07:53:57       2021-10-21 08:19:17.  2021-10-21 10:41:53
  client3     2021-10-21 09:00:00    2021-10-21 10:00:00       --                     --
  client3     2021-10-21 10:00:00    2021-10-22 14:00:00      2021-10-21 10:00:00    2021-10-21 10:00:00
  client2     2021-10-21 10:00:00    2021-10-21 14:00:00    2021-10-21 10:00:00   2021-10-21 14:00:00
  </code></pre>