Suppose I have
a = array([[1, 2],
[3, 4]])
and
b = array([1,1])
I'd like to use b in index a, that is to do a[b] and get 4 instead of [[3, 4], [3, 4]]
I can probably do
a[tuple(b)]
Is there a better way of doing it?
Thanks
Suppose I have
a = array([[1, 2],
[3, 4]])
and
b = array([1,1])
I'd like to use b in index a, that is to do a[b] and get 4 instead of [[3, 4], [3, 4]]
I can probably do
a[tuple(b)]
Is there a better way of doing it?
Thanks
According the numpy tutorial:
a[tuple(b)]
is the correct way to do this:
http://www.scipy.org/Tentative_NumPy_Tutorial#head-3f4d28139e045a442f78c5218c379af64c2c8c9e