I would like to identify the sequences of continuous numbers in a vector, given:
x = [1,1,1,1,2,2,2,2,3,3,3,3,1,1,1,1,2,2,2,2,2,2]
The numpy.unique returns --> [1,2,3] without including the repeated [1,2] at the end of the sequence x.
This what I have tried so far:
import numpy as np
y = np.unique(x)
The expected returns are:
[1,2,3,1,2]
The repeated [1,2] should be kept at the end of the returns just like clustering.