In order to find several minimums in an array using numpy, you can use the numpy.argmin()
method along with indexing. Here's an example:
main.py424 chars16 lines
In this example, we first create an array using numpy. We then find the index of the minimum value in this array using numpy.argmin()
. We create a new boolean array where the values are True
if they are equal to the minimum value. Finally, we use this boolean array to index the original array and get all minimum values.
The output of this example would be [1 2 2]
, which are all the minimum values in the array.
gistlibby LogSnag