Home > OS >  np.max not returning correct output when used on intergers
np.max not returning correct output when used on intergers

Time:06-20

In Python, why does

np.max(-2,0)

return

-2

when

max(-2, 0)

returns

0

Should they not have the same output for integers? Or is np.max used for something else?

CodePudding user response:

The input value to the np.max() function must be a list, please take a look at the official Numpy documentation to know more about its functions, inputs and outputs:

import numpy as np
print(np.max([-2, 0]))

Output:

0
  • Related