Reputation: 1
I run the following code:
import numpy as np
Z = np.arange(9).reshape(3,3)
print(Z[[0,1],[0,2]])
Z is:
0 1 2
3 4 5
6 7 8
I expected to get the values 1 and 2 but got 0 and 5, so I don't understand how this indexing works.
Thanks
Upvotes: 0
Views: 153
Reputation: 56
Z[[0,1],[0,2]] returns Z[0,0] and Z[1,2], that's why you get 0 and 5.
Upvotes: 1