I have an array of numbers, a. I have a second array, b, specifying how many times I want to retrieve the corresponding element in a. How
a
b
A really inefficient way to do that is this one :
import numpy as np a = np.arange(5) b = np.array([1,0,3,2,0]) res = [] i = 0 for val in b: for aa in range(val): res.append(a[i]) i += 1 print res