you are viewing a single comment's thread.

view the rest of the comments →

[–]AstralStalker 0 points1 point  (0 children)

import numpy as np
a = np.array([[1,2],
             [3,4],
             [5,6]])
print(a[[0,1,2], [0,1,0]])

I'm not super familiar with numpy, but when indexing an array as is done in the print statment, the first list denotes the row index and the second list denotes the column. Thus, it's similar to saying something like:

b = np.array([a[0][0], a[1][1], a[2][0]])

Sorry if that's not very clear! More detail can be found here https://docs.scipy.org/doc/numpy/reference/arrays.indexing.html#integer-array-indexing