You can use np.where to return a tuple of arrays of x and y indices where a given condition holds in an array.

If a is the name of your array:

>>> np.where(a == 1)
(array([0, 0, 1, 1]), array([0, 1, 2, 3]))

If you want a list of (x, y) pairs, you could zip the two arrays:

>>> list(zip(*np.where(a == 1)))
[(0, 0), (0, 1), (1, 2), (1, 3)]

Or, even better, @jme points out that np.asarray(x).T can be a more efficient way to generate the pairs.

Answer from Alex Riley on Stack Overflow
🌐
Quora
quora.com › How-do-I-return-the-index-of-an-element-in-a-2D-array-in-Python
How to return the index of an element in a 2D array in Python - Quora
Answer (1 of 2): You don’t return the index - your code needs to keep track of where the elements are. If you are asking how do you search a 2D array - the only way is something like this: [code]def find_all(matrix, element): """Iterate through all row, column indexes in a 2D Matrix where ...
🌐
Stack Overflow
stackoverflow.com › questions › 68355404 › how-to-find-specific-elements-in-2d-array
python - How to find specific elements in 2d array? - Stack Overflow
a2D = np.arraya2D = np.array([[1, 2, 3, 2, 1], [1, 4, 5, 3, 2]]) So if I have an array such as this I am not sure if it's possible to find a specific part of the array in which values are larger t...
🌐
CodingFleet
codingfleet.com › transformation-details › python-program-to-find-value-in-2d-array
Python Program to Find Value in 2D Array - CodingFleet
Created at using the Python Code Generator tool. ... Although these codes and explanations are generated by AI tools, they are manually reviewed for accuracy and work most of the time.
Find elsewhere
🌐
Javatpoint
javatpoint.com › python-2d-array
Python 2D array - Javatpoint
January 10, 2021 - Python 2D array with python, tutorial, tkinter, button, overview, entry, checkbutton, canvas, frame, environment set-up, first python program, operators, etc.
🌐
iO Flood
ioflood.com › blog › python-2d-array
Python 2D Array with Lists | Guide (With Examples)
February 10, 2024 - To access an element, we need three indices – one for the 2D array, one for the row, and one for the column. ... Python’s list comprehensions provide a concise way to create lists.
🌐
Python Like You Mean It
pythonlikeyoumeanit.com › Module3_IntroducingNumpy › AccessingDataAlongMultipleDimensions.html
Accessing Data Along Multiple Dimensions in an Array — Python Like You Mean It
The zero-based indexing schema that we reviewed earlier applies to each axis of the ND-array: -- axis-1 -> -2 -1 0 1 | +---+---+ | -3, 0 |93 | 95| | +---+---+ axis-0 -2, 1 |84 |100| | +---+---+ | -1, 2 |99 | 87| V +---+---+ Because grades has three entries along axis-0 and two entries along axis-1, it has a “shape” of (3, 2). ... Thus, if we want to access Brad’s (item-1 along axis-0) score for Exam 1 (item-0 along axis-1) we simply specify: # providing two numbers to access an element # in a 2D-array >>> grades[1, 0] # Brad's score on Exam 1 84 # negative indices work as with lists/tuples/strings >>> grades[-2, 0] # Brad's score on Exam 1 84
🌐
Stack Overflow
stackoverflow.com › questions › 53738911 › how-to-print-specific-element-of-a-2d-array-via-searching-for-a-matching-value
python - How to print specific element of a 2d array via searching for a matching value - Stack Overflow
3.Find the min value in this last array and take the corresponding index in b ... def search_element(dot): b = [c[1] for c in a] index = min([(abs(f-dot),i) for i,f in enumerate(b)])[1] n = b[index] b = [c[0] for c in a if c[1]==n] return b
🌐
Scaler
scaler.com › home › topics › 2d array in python
2D Array in Python | Python Two-Dimensional Array - Scaler Topics
May 25, 2026 - Each element in a 2D array is represented by two indices, the row and the column. Unlike a one dimensional array, which uses a single index for individual elements, a 2D array uses two indices to locate a value. 2D arrays in python are zero-indexed, which means counting indices start from zero ...
🌐
Guru99
guru99.com › home › python › python 2d arrays: two-dimensional list examples
Python 2D Arrays: Two-Dimensional List Examples
July 10, 2026 - 🔁 How do you loop through a 2D array in Python? Use nested for loops: the outer loop iterates over each row, and the inner loop iterates over the columns inside that row. This lets you read or update every element position by position.