在浮点数数组中找到最小值 [英] find a minimum value in an array of floats

查看:115
本文介绍了在浮点数数组中找到最小值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在python中由100个浮点数组成的数组中找到最小值? 我用import numpy尝试了minindex=darr.argmin()print darr[minindex](darr是数组的名称)

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)

但是我得到: minindex=darr.argmin()

AttributeError: 'list' object has no attribute 'argmin'

可能是什么问题?有更好的选择吗?

what might be the problem? is there a better alternative?

预先感谢

推荐答案

Python具有> c5>内置功能:

>>> darr = [1, 3.14159, 1e100, -2.71828]
>>> min(darr)
-2.71828

这篇关于在浮点数数组中找到最小值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆