numpy: Is there a way to create an array from a sequence of mappings w/o external loop?
I think you are looking for this part of numpy's documentation on indexing.
In [17]: mapping[(np.arange(indices.shape[-1]),indices)]Out[17]: array([ 25, 177, 0, 10])
This create a temporary array (np.arange
) but it is 1-dimensional and I couldn't think of anything better.