Say I have the following numpy array:
a = np.array([1,5,5,2,3,6,5,2,5,5,5])
I'm trying to come up with a numpy solution to count the amount of times a given value appears consecutively. So, for example for number 5 I'd like to get:
array([2,1,3])
As it appears consecutively 3 times in the array, with the specified amount of repetitions on each time.
[sum(1 for _ in group) for key, group in itertools.groupby(a) if key == 5]