[Numpy-discussion] Silly array question
Webb Sprague
webb.sprague at gmail.com
Fri Apr 7 12:36:00 EDT 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).
Example
I = [[0,0], [1,1], [2,2], [1,1]]
M = [[1, 2, 3, 4],
[5, 6, 7, 8],
[9,10,11, 12],
[13, 14, 15, 16]]
M[I] = [1,6,11,6].
Thanks!
More information about the NumPy-Discussion
mailing list