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
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
According the NumPy tutorial, the correct way to do it is: