title: Make a new column from grouped data
body: <p>I have a pandas Dataframe as below- </p>
  
  <pre class="lang-py prettyprint-override"><code>id  session_id  timestamp   url
  1      #123        1       a.com
  1      #123        2       a.com
  1      #123        3       b.com
  1      #123        4       b.com
  1      #123        5       a.com
  1      #546        37      c.com
  2      #342        78      b.com
  2      #674        79      c.com
  </code></pre>
  
  <p>I want to group all data using <code>id</code> then <code>session_id</code> and calculate the total timespent on each url.</p>
  
  <p>code to make DataFrame - </p>
  
  <pre class="lang-py prettyprint-override"><code>pd.DataFrame({
      'id':[1, 1, 1, 1, 1, 1, 2, 2],
      'session_id':['#123', '#123', '#123', '#123', '#123', '#546', '#342', '#674'],
      'url':['a.com', 'a.com', 'b.com', 'b.com', 'a.com', 'c.com', 'b.com', 'c.com'],
      'timestamp':[1,2,3,4,5,37,78,79]
  })
  </code></pre>
  
  <blockquote>
    <p>Timespent is calculated as <code>2(timestamp)-1(timestamp)=1</code> (actual data has timestamp as UNIX timestamp), now for id
    <code>1</code> and session_id <code>#123</code> - <code>a.com</code> has total_timespent as (2-1)+(5-4) =
    2 (because 3,4 timestamp is for <code>b.com</code>)</p>
  </blockquote>
  
  <p><strong>Expected Output -</strong>  </p>
  
  <pre class="lang-py prettyprint-override"><code>id  session_id  timestamp   url    total_time
  1      #123        1       a.com       2
  1      #123        2       a.com       2
  1      #123        3       b.com       2
  1      #123        4       b.com       2
  1      #123        5       a.com       2
  1      #546        37      c.com       0
  2      #342        78      b.com       0
  2      #674        79      c.com       0
  </code></pre>
  
  <p>here time for a url is broadcasted to all rows for a url  (as per id and session_id)</p>