Yes, given an array, array, and a value, item to search for, you can use np.where as:

itemindex = numpy.where(array == item)

The result is a tuple with first all the row indices, then all the column indices.

For example, if an array is two dimensions and it contained your item at two locations then

array[itemindex[0][0]][itemindex[1][0]]

would be equal to your item and so would be:

array[itemindex[0][1]][itemindex[1][1]]
Answer from Alex on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › python › how-to-find-the-index-of-value-in-numpy-array
How to find the Index of value in Numpy Array ? - GeeksforGeeks
July 23, 2025 - where() method is used to specify the index of a particular element specified in the condition. ... Here, we find all the indexes of 3 and the index of the first occurrence of 3, we get an array as output and it shows all the indexes where 3 ...
Discussions

python - Index of element in NumPy array - Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most. Learn more about Collectives ... Bring the best of human thought and AI automation together at your work. Explore Stack Internal ... Closed 5 years ago. In Python we can get the index of a value in an array by ... More on stackoverflow.com
🌐 stackoverflow.com
efficiently finding the index of a value in a numpy array
You can use np.where(OPs_array==value) to get the indices. But if that is the main use of your array then consider using a dictionary. More on reddit.com
🌐 r/learnpython
1
3
September 9, 2022
How to find index of value in NumPy array? - Data Exploration & Visualization - Data Science Dojo Discussions
Suppose I have an array that contains zero and non-zero values. Now I want to find the index of non-zero values of my array. I tried many methods previously, but they are not giving me the desired result. Can someone help me with this? More on discuss.datasciencedojo.com
🌐 discuss.datasciencedojo.com
3
0
February 17, 2023
How can you find the index an element has in the NumPy array that a slice was made from?
Same way you find an index in a because b will be same type as a. I don't remember off the top of my head (and I really should!!) if it works for numpy, but my first guess is b.index(element), which is just what you'd do with a list. More on reddit.com
🌐 r/learnpython
4
2
July 17, 2022
🌐
W3Schools
w3schools.com › python › numpy › numpy_array_search.asp
NumPy Searching Arrays
You can search an array for a certain value, and return the indexes that get a match. To search an array, use the where() method. ... import numpy as np arr = np.array([1, 2, 3, 4, 5, 4, 4]) x = np.where(arr == 4) print(x) Try it Yourself »
🌐
Reddit
reddit.com › r/learnpython › efficiently finding the index of a value in a numpy array
r/learnpython on Reddit: efficiently finding the index of a value in a numpy array
September 9, 2022 -

I have a numpy array that has unique values and is static, and I routinely want to find some index of a value. Is it a good idea to repeatedly use where for this? Is numpy sorting the values and storing a mapping of them to the indices behind the scene, or otherwise doing something smart to quickly find the index? If not, what would be a good way to implement finding the index of a value in a numpy array?

🌐
GeeksforGeeks
geeksforgeeks.org › python › find-index-of-element-in-array-in-python
Find index of element in array in python - GeeksforGeeks
July 23, 2025 - import numpy as np arr = np.array([10, 20, 30, 40, 30, 50]) element = 30 # Find indices indices = np.where(arr == element)[0] print("Indices:", indices) ... We can use a similar for with lists to search for an element by looping through the list.
Find elsewhere
🌐
Delft Stack
delftstack.com › home › howto › numpy › index of element in array
How to Find the First Index of Element in NumPy Array | Delft Stack
March 11, 2025 - One of the simplest and most effective methods to find the first index of an element in a NumPy array is by utilizing the np.where() function. This function returns the indices of elements that satisfy a given condition.
🌐
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.
🌐
thisPointer
thispointer.com › home › python › find the index of value in numpy array using numpy.where()
Find the index of value in Numpy Array using numpy.where() - thisPointer
April 1, 2023 - Today, we learned about different ways to find the indices of elements in a NumPy Array. Find max value & its index in Numpy Array | numpy.amax() ... Create Numpy Array of different shapes & initialize with identical values using numpy.full() in Python
🌐
Statology
statology.org › home › how to find index of value in numpy array (with examples)
How to Find Index of Value in NumPy Array (With Examples)
September 17, 2021 - This tutorial explains how to find the index location of specific values in a NumPy array, including examples.
🌐
Data Science Dojo
discuss.datasciencedojo.com › data exploration & visualization
How to find index of value in NumPy array? - Data Exploration & Visualization - Data Science Dojo Discussions
February 17, 2023 - Suppose I have an array that contains zero and non-zero values. Now I want to find the index of non-zero values of my array. I tried many methods previously, but they are not giving me the desired result. Can someone hel…
🌐
Sololearn
sololearn.com › en › Discuss › 2579971 › how-i-get-the-index-of-element-in-numpy-array
how i get the index of element in numpy array?
November 7, 2020 - Sololearn is the world's largest community of people learning to code. With over 25 programming courses, choose from thousands of topics to learn how to code, brush up your programming knowledge, upskill your technical ability, or stay informed about the latest trends.
🌐
sqlpey
sqlpey.com › python › finding-element-indices-in-numpy-arrays
Finding Element Indices in NumPy Arrays: Techniques and Performance
November 4, 2025 - Checking for presence first (if ... approach for 1D arrays is to convert the NumPy array to a standard Python list and use the list’s built-in .index() method....
🌐
APXML
apxml.com › courses › essential-numpy-pandas › chapter-3-numpy-array-indexing-slicing › accessing-single-elements
Access NumPy Array Elements
The simplest case is a one-dimensional array, which is like a list or sequence of values. In Python, and therefore in NumPy, indexing starts at 0. This means the first element is at index 0, the second element is at index 1, and so on.
🌐
Reddit
reddit.com › r/learnpython › how do i get the index number of a numpy array?
r/learnpython on Reddit: How do I get the index number of a numpy array?
May 14, 2023 -
In [1]: import numpy as np
In [2]: a = np.array([0,0,0,0])
In [3]: b = np.array([1,0,0,0])
In [4]: c = np.where(a != b)
In [5]: print(c)
(array([0], dtype=int64),)

How do I get the value "0" out of the return of "c" ?

Top answer
1 of 2
1
What does c[0] print? What can you do next?
2 of 2
1
Hey OP, made this little playground for you based on your description of your case. I assume when you said "I have two arrays that represent on/off states of a row of switches" that you were referring to a "previous state" and "current state" arrays like a and b in your example. In this code, a random number of switches are flipped during a trial (5 trials performed). The report_changes function illustrates how you can get a printout of the positions, even if only one position changes. The demo code is just for setup, but feel free to study it to get a sense of how numpy can operate. import numpy as np np.random.seed(0) def report_changes(previous, current): # We assume previous & current are 1D arrays locs_of_changes = np.nonzero(previous != current)[0] # [0] gets the array out of the tuple since its the first element # Remember, locs_of_changes is itself an array! if locs_of_changes.size == 1: print(f'1 change at position {locs_of_changes[0]}') else: print(f'{locs_of_changes.size} changes at positions {locs_of_changes}') # Setup prev_state = np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) current_state = prev_state.copy() # For demo purposes for _ in range(5): # We will change an arbitrary number of values to their opposite (0 -> 1, 1 -> 0) n_changes = np.random.randint(1, 3) positions_to_change = np.random.choice(current_state.size, n_changes, replace=False) current_state[positions_to_change] = ~current_state[positions_to_change].astype(bool) # Printout print(f"Current state: {current_state}") print(f"Previous state: {prev_state}") report_changes(prev_state, current_state) prev_state = current_state.copy() print("=" * 50) EDIT: Since you're new to Python, remember that Python is 0-index based. Meaning, 0 is the first position, 1 is the second position, 2 is the third, etc.