Give unique identifier to consecutive groupings
<p>I'm trying to identify groups based on sequential numbers. For example, I have a dataframe that looks like this (simplified):</p>

<pre><code>UID
1
2
3
4
5
6
7
11
12
13
15
17
20
21
22
</code></pre>

<p>And I would like to add a column that identifies when there are groupings of consecutive numbers, for example, 1 to 7 are first consecutive , then they get 1 , the second consecutive set will get 2 etc .</p>

<pre><code>UID Group
1   1
2   1
3   1
4   1
5   1
6   1
7   1
11  2
12  2
13  2
15  3
17  4
20  5
21  5
22  5
</code></pre>

<p>none of the existed code helped me to solved this issue</p>