If I understand it correctly, you have a list of coordinates like this:

coords = [[y0, x0], [y1, x1], ...]

To get the values of array a at these coordinates you need:

a[[y0, y1, ...], [x0, x1, ...]]

So a[coords] will not work. One way to do it is:

Y = [c[0] for c in coords]
X = [c[1] for c in coords]

or

Y = np.transpose(coords)[0]
X = np.transpose(coords)[1]

Then

a[Y, X]
Answer from kuzand on Stack Overflow
🌐
NumPy
numpy.org › devdocs › user › absolute_beginners.html
NumPy: the absolute basics for beginners — NumPy v2.6.dev0 Manual
Using np.newaxis will increase the dimensions of your array by one dimension when used once. This means that a 1D array will become a 2D array, a 2D array will become a 3D array, and so on.
Top answer
1 of 3
6

We can compute the linear indices and then use np.take -

np.take(lut, np.ravel_multi_index(arr.T, lut.shape)).T

If you are open to alternatives, we can reshape the indices array to 2D, convert to tuples, index into the data array with it, to give us 1D, which could be reshaped back to 2D -

lut[tuple(arr.reshape(-1,arr.shape[-1]).T)].reshape(arr.shape[:2])

Sample run -

In [49]: lut = np.random.randint(11,99,(13,13,13))

In [50]: arr = np.arange(12).reshape([2,2,3])

In [51]: lut[ arr[:,:,0],arr[:,:,1],arr[:,:,2] ] # Original approach
Out[51]: 
array([[41, 21],
       [94, 22]])

In [52]: np.take(lut, np.ravel_multi_index(arr.T, lut.shape)).T
Out[52]: 
array([[41, 21],
       [94, 22]])

In [53]: lut[tuple(arr.reshape(-1,arr.shape[-1]).T)].reshape(arr.shape[:2])
Out[53]: 
array([[41, 21],
       [94, 22]])

We can avoid the double transposing for the np.take approach, like so -

In [55]: np.take(lut, np.ravel_multi_index(arr.transpose(2,0,1), lut.shape))
Out[55]: 
array([[41, 21],
       [94, 22]])

Generalize to multi-dimensional arrays of generic dimensions

This could be generalized to ndarrays of generic no. of dims, like so -

np.take(lut, np.ravel_multi_index(np.rollaxis(arr,-1,0), lut.shape))

The tuple-based approach should work without any change.

Here's a sample run for the same -

In [95]: lut = np.random.randint(11,99,(13,13,13,13))

In [96]: arr = np.random.randint(0,13,(2,3,4,4))

In [97]: lut[ arr[:,:,:,0] , arr[:,:,:,1],arr[:,:,:,2],arr[:,:,:,3] ]
Out[97]: 
array([[[95, 11, 40, 75],
        [38, 82, 11, 38],
        [30, 53, 69, 21]],

       [[61, 74, 33, 94],
        [90, 35, 89, 72],
        [52, 64, 85, 22]]])

In [98]: np.take(lut, np.ravel_multi_index(np.rollaxis(arr,-1,0), lut.shape))
Out[98]: 
array([[[95, 11, 40, 75],
        [38, 82, 11, 38],
        [30, 53, 69, 21]],

       [[61, 74, 33, 94],
        [90, 35, 89, 72],
        [52, 64, 85, 22]]])
2 of 3
1

I did not try in 3-dimensions. But in 2-dimensions I get the result I want with using numpy.take :

np.take(np.take(T,ix,axis=0), iy,axis=1 )

Perhaps you can expand that to 3-dimensions.

As an example I can adress with two 1-dim arrays for the indices ix and iy the 2-dimensional stencil for the discrete Laplace equation,

ΔT = T[ix-1,iy] + T[ix+1, iy] + T[ix,iy-1] + T[ix,iy+1] - 4*T[ix,iy]

Introducing for a leaner writing:

def q(Φ,kx,ky):
    return np.take(np.take(Φ,kx,axis=0), ky,axis=1 )

then I can run the following python code with numpy.take:

nx = 6; ny= 10
T  = np.arange(nx*ny).reshape(nx, ny)

ix = np.linspace(1,nx-2,nx-2,dtype=int) 
iy = np.linspace(1,ny-2,ny-2,dtype=int)

ΔT = q(T,ix-1,iy)  + q(T,ix+1,iy)  + q(T,ix,iy-1)  + q(T,ix,iy+1)  - 4.0 * q(T,ix,iy)
🌐
Python Like You Mean It
pythonlikeyoumeanit.com › Module3_IntroducingNumpy › AccessingDataAlongMultipleDimensions.html
Accessing Data Along Multiple Dimensions in an Array — Python Like You Mean It
Note the value of using the negative index is that it will always provide you with the latest exam score - you need not check how many exams the students have taken. What happens if we only supply one index to our array? It may be surprising that grades[0] does not throw an error since we are specifying only one index to access data from a 2-dimensional array. Instead, NumPy it will return all of the exam scores for student-0 (Ashley):
🌐
Codecademy
codecademy.com › docs › python:numpy › ndarray › take()
Python:NumPy | ndarray | take() | Codecademy
October 31, 2025 - import numpy as np · arr = ... above will return an error. In this example, ndarray.take() is applied to a 2D array to extract rows, columns, and wrapped indices: Visit us ·...
🌐
NumPy
numpy.org › doc › stable › reference › generated › numpy.take.html
numpy.take — NumPy v2.5 Manual
When axis is not None, this function does the same thing as “fancy” indexing (indexing arrays using arrays); however, it can be easier to use if you need elements along a given axis. A call such as np.take(arr, indices, axis=3) is equivalent to arr[:,:,:,indices,...].
🌐
DataCamp
campus.datacamp.com › courses › intro-to-python-for-data-science › chapter-4-numpy
2D NumPy Arrays | Python
The arrays np_height and np_weight are one-dimensional arrays, but it's perfectly possible to create 2 dimensional, three dimensional, heck even seven dimensional arrays! Let's stick to 2 in this video though. You can create a 2D numpy array from a regular Python list of lists.
🌐
Drbeane
drbeane.github.io › python_dsci › pages › array_2d.html
2-Dimensional Arrays — Python for Data Science
Notice that the array that is printed above is not displayed in the form of a column. In fact, when slicing a single row or a column out of a 2D array, the result is returned as a simple 1D array. Every Numpy array comes equipped with a shape attribute that we can use to determine the shape of the array.
Find elsewhere
🌐
W3Schools
w3schools.com › python › numpy › numpy_array_slicing.asp
NumPy Array Slicing
Slice elements from index 4 to the end of the array: import numpy as np arr = np.array([1, 2, 3, 4, 5, 6, 7]) print(arr[4:]) Try it Yourself »
🌐
NumPy
numpy.org › doc › 2.2 › reference › generated › numpy.take.html
numpy.take — NumPy v2.2 Manual
When axis is not None, this function does the same thing as “fancy” indexing (indexing arrays using arrays); however, it can be easier to use if you need elements along a given axis. A call such as np.take(arr, indices, axis=3) is equivalent to arr[:,:,:,indices,...].
🌐
NumPy
numpy.org › doc › stable › reference › arrays.ndarray.html
The N-dimensional array (ndarray) — NumPy v2.5 Manual
An ndarray object has many methods which operate on or with the array in some fashion, typically returning an array result. These methods are briefly explained below. (Each method’s docstring has a more complete description.) For the following methods there are also corresponding functions in numpy: all, any, argmax, argmin, argpartition, argsort, choose, clip, compress, copy, cumprod, cumsum, diagonal, imag, max, mean, min, nonzero, partition, prod, put, ravel, real, repeat, reshape, round, searchsorted, sort, squeeze, std, sum, swapaxes, take, trace, transpose, var.
🌐
OpenGenus
iq.opengenus.org › 2d-array-in-numpy
2D Arrays in NumPy (Python)
October 28, 2022 - For working with numpy we need to first import it into python code base. ... To get a specific element from an array use arr[r,c] here r specifies row number and c column number.
🌐
NumPy
numpy.org › doc › 2.1 › reference › generated › numpy.ndarray.take.html
numpy.ndarray.take — NumPy v2.1 Manual
Return an array formed from the elements of a at the given indices. Refer to numpy.take for full documentation.
🌐
NumPy
numpy.org › doc › 2.3 › reference › generated › numpy.ndarray.take.html
numpy.ndarray.take — NumPy v2.3 Manual
Return an array formed from the elements of a at the given indices. Refer to numpy.take for full documentation.
🌐
Python Guides
pythonguides.com › python-numpy-2d-array
Create A 2D NumPy Array In Python (5 Simple Methods)
May 9, 2025 - Cells, rows, columns and slices of a 2D sales array. import numpy as np matrix = [[1, 2], [3, 4]] matrix.append([5, 6]) # add a row to a nested list for row in matrix: row.append(0) # add a column print(matrix) arr = np.array([[1, 2], [3, 4]]) ...
🌐
Sdsu
gawron.sdsu.edu › python_for_ss › course_core › book_draft › data › numpy.html
6.2. More on two-dimensional arrays — python_for_ss 0.1.1 documentation
Boolean operations work more or less as expected on 2D arrays: import numpy as np y = np.arange(35).reshape(5,7) y>3
🌐
YouTube
youtube.com › dan leeman
Python NumPy | 2D Arrays - YouTube
NumPy arrays are capable of holding multidimensions of data. Just like a single dimension array, calculations will occur on each element within the array and...
Published: June 7, 2019
Views: 16K