title: How to merge timestamps that are only few seconds apart [Pandas]
body: <p>I have this dataframe with shape 22341x3: </p>
  
  <pre><code>    tID   DateTime
  0   1     2020-04-04 10:15:40
  1   2     2020-04-04 10:15:56
  2   2     2020-04-04 11:07:11
  3   3     2020-04-04 11:08:14
  4   3     2020-04-04 11:18:46
  5   4     2020-04-04 11:23:56
  6   5     2020-04-04 11:24:14
  7   6     2020-04-04 11:29:12
  8   7     2020-04-04 11:29:23
  9   8     2020-04-04 11:34:23
  </code></pre>
  
  <p>Now I have to create a column called <code>merged_timestamp</code> that merges all the timestamps that are only a few seconds apart and give them a new number: <code>mtID</code></p>
  
  <p>So for example: if we consider <code>2020-04-04 10:15:40</code> as a reference, the timestamps with few seconds apart can be from <code>40</code> seconds until <code>44</code> seconds. They can have hours and minutes with a big gap as compared to the reference, but their seconds should be only few seconds apart in order to get merged. </p>
  
  <p>Any help would be appreciated. </p>
  
  <p>EDIT: I tried doing <code>dfd.resample('5s')[0:5]</code> where dfd is my dataframe. It gives me this error <code>TypeError: Only valid with DatetimeIndex, TimedeltaIndex or PeriodIndex, but got an instance of 'RangeIndex'</code></p>