Skip to content
Advertisement

Numpy: Indexing 3D matrix using 1D array

JavaScript

I’m trying to index this array of shape (3,2,2) with an array of shape (3) containing the y-index of the value I want to get. I tried to make it work with for in statement, but is there an elegant way to do it with numpy?

Advertisement

Answer

So you want arr[0,0,:], arr[1,1,:], arr[2,1,:]?

How about

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement