Have you thought about using Python list's .index(value) method? It return the index in the list of where the first instance of the value passed in is found.
efficiently finding the index of a value in a numpy array
How to find index of element? - Python - Data Science Dojo Discussions
How to find index of value in NumPy array? - Data Exploration & Visualization - Data Science Dojo Discussions
Why no .get(idx[, default]) on python list??
Videos
Have you thought about using Python list's .index(value) method? It return the index in the list of where the first instance of the value passed in is found.
Without actually seeing your data it is difficult to say how to find location of max and min in your particular case, but in general, you can search for the locations as follows. This is just a simple example below:
In [9]: a=np.array([5,1,2,3,10,4])
In [10]: np.where(a == a.min())
Out[10]: (array([1]),)
In [11]: np.where(a == a.max())
Out[11]: (array([4]),)
Alternatively, you can also do as follows:
In [19]: a=np.array([5,1,2,3,10,4])
In [20]: a.argmin()
Out[20]: 1
In [21]: a.argmax()
Out[21]: 4
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?