Search code examples
pythonarraysnumpyminimum

python: Returning mininum in numpy.ndarray


I have an array [test] of type numpy.ndarray:

[' -0.1 ' ' -0.4 ' ' -0.6 ' ' -0.2 ' ' -3.4 ' ' 0.0 ' ' -1.9 ' ' -1.2 ' ' -0.5 ']

and want to find the minimum value.

If I do print min(test) the value returned is -0.1 which is not the minimum (i.e. -3.4)

How do I correctly return the minimum value.


Solution

  • Convert first:

    test.astype(float).min()