how would one go about finding the minimum value in an array of 100 floats in python? I have tried minindex=darr.argmin()
and print darr[minindex]
with import numpy
(darr is the name of the array)
but i get: minindex=darr.argmin()
AttributeError: 'list' object has no attribute 'argmin'
what might be the problem? is there a better alternative?
thanks in advance
In python is very easy to find out maximum, minimum element and their position also. Python provides different inbuilt function. min() is used for find out minimum value in an array, max() is used for find out maximum value in an array. index() is used for finding the index of the element.
Use JavaScript reduce() or Math method to get the min value in an array of objects. Using the Math functions with the spread operator (…) and sorting the array numerically with . sort() is a way to get the min value-form an array.
Python has a min()
built-in function:
>>> darr = [1, 3.14159, 1e100, -2.71828] >>> min(darr) -2.71828
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With