I would like to get the unique element from an array with specific sequences.
For example,
initially, I have array as following:
array([3, 3, 6, 6, 5, 5, 5, 5, 2, 8, 8])
I would like to get the unique element from the array above and maintain its original order sequence. The sample output as following:
array([3, 6, 5, 2, 8])
I know that using numpy.unique()
will get the unique elements for the array, but it will return sorted unique elements. However, in my case, I need the output in the original sequence.
To generate toy example, here easy for you to just copy & paste
arr = np.array([3,3,6,6,5,5,5,5,2,8,8])
At the time I post this, I still working on this, and I wish to get your suggestion so that I could move to the next part of work. Your advice will be highly appreciated. Thank you for your time!