According the NumPy tutorial, the correct way to do it is:

a[tuple(b)]
Answer from JoshAdel on Stack Overflow
๐ŸŒ
NumPy
numpy.org โ€บ devdocs โ€บ user โ€บ basics.indexing.html
Indexing on ndarrays โ€” NumPy v2.5.dev0 Manual
As in Python, all indices are zero-based: for the i-th index \(n_i\), the valid range is \(0 \le n_i < d_i\) where \(d_i\) is the i-th element of the shape of the array. Negative indices are interpreted as counting from the end of the array (i.e., if \(n_i < 0\), it means \(n_i + d_i\)). All arrays generated by basic slicing are always views of the original array. ... NumPy slicing creates a view instead of a copy as in the case of built-in Python sequences such as string, tuple and list.
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ numpy โ€บ numpy_array_indexing.asp
NumPy Array Indexing
You can access an array element by referring to its index number. The indexes in NumPy arrays start with 0, meaning that the first element has index 0, and the second has index 1 etc.
Discussions

python - Indexing numpy array with another numpy array - Stack Overflow
IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices More on stackoverflow.com
๐ŸŒ stackoverflow.com
python - Index of element in NumPy array - Stack Overflow
Both take the same number of characters, but the first method returns an int instead of a numpy.ndarray. ... Don't be torn ;-) The first method returns the index of the first matching element., and raises a ValueError if var is not in the list. The second method returns an array of all matching ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
Indexing a np.array with another np.array
Hello, I'm a Reddit bot who's here to help people nicely format their coding questions. This makes it as easy as possible for people to read your post and help you. I think I have detected some formatting issues with your submission: Python code found in submission text that's not formatted as code. If I am correct, please edit the text in your post and try to follow these instructions to fix up your post's formatting. Am I misbehaving? Have a comment or suggestion? Reply to this comment or raise an issue here . More on reddit.com
๐ŸŒ r/learnpython
4
1
July 14, 2022
Numpy array of Decimal objects for efficient indexing or other basic operations?
It can be done, but they will be stored as "object" type and you will lose all the speed advantages of a numpy array. So most of the time it makes more sense to just use a normal python list. Do you know numpy has a float128 type? Perhaps that's enough precision for you? https://numpy.org/doc/1.22/reference/arrays.scalars.html#numpy.longdouble More on reddit.com
๐ŸŒ r/learnpython
8
2
June 27, 2024
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ numpy-indexing
Numpy Array Indexing - GeeksforGeeks
December 17, 2025 - Array indexing in NumPy refers to the method of accessing specific elements or subsets of data within an array. This feature allows us to retrieve, modify and manipulate data at specific positions or ranges helps in making it easier to work ...
๐ŸŒ
DataCamp
datacamp.com โ€บ doc โ€บ numpy โ€บ array-indexing
NumPy Array Indexing
NumPy array indexing is used to extract or modify elements in an array based on their indices.
๐ŸŒ
NumPy
numpy.org โ€บ doc โ€บ stable โ€บ user โ€บ basics.indexing.html
Indexing on ndarrays โ€” NumPy v2.4 Manual
As in Python, all indices are zero-based: for the i-th index \(n_i\), the valid range is \(0 \le n_i < d_i\) where \(d_i\) is the i-th element of the shape of the array. Negative indices are interpreted as counting from the end of the array (i.e., if \(n_i < 0\), it means \(n_i + d_i\)). All arrays generated by basic slicing are always views of the original array. ... NumPy slicing creates a view instead of a copy as in the case of built-in Python sequences such as string, tuple and list.
๐ŸŒ
NumPy
numpy.org โ€บ doc โ€บ stable โ€บ user โ€บ absolute_beginners.html
NumPy: the absolute basics for beginners โ€” NumPy v2.4 Manual
It is familiar practice in mathematics to refer to elements of a matrix by the row index first and the column index second. This happens to be true for two-dimensional arrays, but a better mental model is to think of the column index as coming last and the row index as second to last.
Find elsewhere
๐ŸŒ
Quansight-labs
quansight-labs.github.io โ€บ ndindex โ€บ indexing-guide โ€บ index.html
Guide to NumPy Indexing - ndindex documentation
This section is itself split into six subsections. First is a basic introduction to what a NumPy array is. Following this are pages for each of the remaining index types, the basic indices: tuples, ellipses, and newaxis; and the advanced indices: integer arrays and boolean arrays (i.e., masks).
๐ŸŒ
NumPy
numpy.org โ€บ doc โ€บ stable โ€บ user โ€บ how-to-index.html
How to index ndarrays โ€” NumPy v2.4 Manual
Use Basic indexing features like Slicing and striding, and Dimensional indexing tools. >>> a = np.arange(30).reshape(2, 3, 5) >>> a array([[[ 0, 1, 2, 3, 4], [ 5, 6, 7, 8, 9], [10, 11, 12, 13, 14]], [[15, 16, 17, 18, 19], [20, 21, 22, 23, 24], [25, 26, 27, 28, 29]]]) >>> a[0, 2, :] array([10, 11, 12, 13, 14]) >>> a[0, :, 3] array([ 3, 8, 13])
๐ŸŒ
CodeSignal
codesignal.com โ€บ learn โ€บ courses โ€บ numpy-basics โ€บ lessons โ€บ array-indexing-and-slicing-in-numpy
Array Indexing and Slicing in NumPy - Python
A NumPy array is a powerful tool for numerical operations. Here's how we import NumPy and create a simple array: ... Array indexing lets us access an element in an array. It works just like with Python's lists! Python uses zero-based indexing, meaning the first element is at position 0.
๐ŸŒ
Reddit
reddit.com โ€บ r/learnpython โ€บ indexing a np.array with another np.array
r/learnpython on Reddit: Indexing a np.array with another np.array
July 14, 2022 -

Indexing one array with another array has different behavior than if I index with the same array without explicitly casting it to a numpy array first (i.e. I leave it as a list of lists). I can't find the pages in the documentation that explain this kind of indexing

Example:

  #make a 5x5 matrix for testing, the numbers arent important 
  a = np.random.rand(5,5)

  #another arbitrary 5x5 matrix
  b = [[0, 0, 0, 0, 1],
         [0, 0, 0, 1, 1],
         [0, 0, 1, 1, 0],
         [0, 1, 1, 0, 0],
         [1, 1, 0, 0, 0]]

  c = np.array(b)

  a[b] #gives the error "too many indices for array: array is 2-dimensional, but 5 were indexed"

  a[tuple(c)] #gives the same error as a[b]

  a[c] #for some reason this works, and it returns a 5x5x5 matrix 

So the behavior changes when I convert the list of lists to a numpy array. And I can't really tell what it's doing by looking at the output of a[c]. It seems to be switching the rows around somehow but I'm confused at why it returns five copies of the original matrix. Is there any page in the documentation that describes this type of indexing?

๐ŸŒ
Programiz
programiz.com โ€บ python-programming โ€บ numpy โ€บ array-indexing
Numpy Array Indexing (With Examples)
In NumPy, each element in an array is associated with a number.In NumPy, each element in an array is associated with a number. The number is known as an array index. Let's see an example to demonstrate NumPy array indexing. Array Indexing in NumPy In the above array, 5 is the 3rd element.
๐ŸŒ
Medium
medium.com โ€บ @whyamit404 โ€บ basics-of-numpy-array-indexing-9052e6d6b5cf
Basics of NumPy Array Indexing. If you think you need to spend $2,000โ€ฆ | by whyamit404 | Medium
February 9, 2025 - Whether you want a specific range or skip every other slice, NumPy makes it easy. Letโ€™s dive into the details! Slicing allows you to grab a portion of your array using the syntax: start:stop:step Hereโ€™s how it works: Start: The index where your slice begins (inclusive).
๐ŸŒ
Python Like You Mean It
pythonlikeyoumeanit.com โ€บ Module3_IntroducingNumpy โ€บ AdvancedIndexing.html
Advanced Indexing โ€” Python Like You Mean It
The index-arrays must have the same shape as one another, and this common shape determines the shape of the resulting array. This is a form of advanced indexing, and thus a copy of the parent arrayโ€™s data is created. NumPy also permits the use of a boolean-valued array as an index, to perform advanced indexing on an array.
๐ŸŒ
Scaler
scaler.com โ€บ home โ€บ topics โ€บ numpy โ€บ indexing and slicing numpy arrays
Indexing and Slicing NumPy Arrays - Scaler Topics
May 4, 2023 - NumPy indexing is used for accessing an element from an array by giving it an index value that starts from 0. Slicing NumPy arrays means extracting elements from an array in a specific range.
๐ŸŒ
Canard Analytics
canardanalytics.com โ€บ blog โ€บ index-slicing-numpy-arrays
Indexing and Slicing NumPy Arrays | Canard Analytics
July 10, 2022 - Sub arrays are created using NumPy slice notation which is a powerful data manipulation technique. ... This NumPy tutorial focuses on the indexing and slicing of NumPy arrays.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ indexing-multi-dimensional-arrays-in-python-using-numpy
Indexing Multi-dimensional arrays in Python using NumPy - GeeksforGeeks
November 4, 2025 - Indexing in multi-dimensional arrays allows us to access, modify or extract specific elements or sections from arrays efficiently. In Python, NumPy provides tools to handle this through index numbers, slicing and reshaping.
๐ŸŒ
Python Like You Mean It
pythonlikeyoumeanit.com โ€บ Module3_IntroducingNumpy โ€บ BasicIndexing.html
Introducing Basic and Advanced Indexing โ€” Python Like You Mean It
Thus far we have seen that we can access the contents of a NumPy array by specifying an integer or slice-object as an index for each one of its dimensions. Indexing into and slicing along the dimensions of an array are known as basic indexing.
๐ŸŒ
Simon Fraser University
sfu.ca โ€บ ~jtmulhol โ€บ py4math โ€บ numpy โ€บ 02-indexing
Array Indexing - NumPy
Now that we know how to build arrays, let's look at how to pull values our of an array using indexing, and also slicing off sections of an array. This is how to select elements and groups of elements from an array. import numpy as np arr = np.arange(0,11) # create an array arr