I have a numpy vector of counts such as this
[2, 4, 3]
and I am trying to create an array of its indexes
[0, 1, 2]
with each index repeated the number times specified by the corresponding count, ie, the final output should be
[0, 0, 1, 1, 1, 1, 2, 2, 2]
It's easy but inefficient to do this using a for loop. Is there a fast vectorized solution?