[Numpy-discussion] Silly array question
webb.sprague at gmail.com
Fri Apr 7 12:36:00 CDT 2006
In R, if you have an Nx2 array of integers, you can use that to index
an TxS array, yielding a 1xN result. Is there a way to do that in
numpy? I looked for a pairs function but I coudn't find it, vaguely
remembering that might be around... I know it would be a trivial loop
to write, but a numpy array function would be faster (I hope).
I = [[0,0], [1,1], [2,2], [1,1]]
M = [[1, 2, 3, 4],
[5, 6, 7, 8],
[13, 14, 15, 16]]
M[I] = [1,6,11,6].
More information about the Numpy-discussion