if you work with numpy
arrays, you could use a simple diff
filter to mask repeated elements:
import numpy as np
a = np.array([5,5,5,5,3,3,2,2,2,2,5,5,5,2,2,2,2,2])
mask = np.ones(a.shape).astype(np.bool_)
mask[1:] = np.diff(a).astype(np.bool_) # prepend a 'True', adjust if not 1D
b = a[mask]
# [5 3 2 5 2]