1

I'm new to python, and now try to understand the argmin() and argmax() function in Numpy.

The code for example is shown as follows:

import numpy as np
b = np.array([4,9,13,20])
print(b.argmin(),b.argmax())

it returns '0' and '3', which represent the locations of the minimum and maximun of the array.

Now we turn to another example:

import numpy as np
b = np.array([4,9,13,20])
c = b>10  #array([False, False,  True,  True])
print(c.argmin(),c.argmax())

The results are 0 and 2. How to understand the 0 and 2 in the results?

In my opinion, the 2 means the first occerrence of the 'True' in c, but how do we understand the 0 in the result?

Anyone can explain? Thanks.

Yongwu Xiu
  • 125
  • 1
  • 9

0 Answers0