0

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.

3
  • 4
    Convert to float values? Commented Aug 8, 2018 at 12:40
  • 5
    It looks like the values in your array are strings, not numbers. Take a look at test.dtype. Commented Aug 8, 2018 at 12:41
  • 1
    I'm pretty sure it's a list of strings too... the min gives -0.1 for strings and -3.4 for floats Commented Aug 8, 2018 at 12:42

1 Answer 1

4

Convert first:

test.astype(float).min()
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.