Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
python:在numpy.ndarray中返回mininum_Python_Arrays_Numpy_Minimum - Fatal编程技术网

python:在numpy.ndarray中返回mininum

python:在numpy.ndarray中返回mininum,python,arrays,numpy,minimum,Python,Arrays,Numpy,Minimum,我有一个numpy.ndarray类型的数组[test]: [' -0.1 ' ' -0.4 ' ' -0.6 ' ' -0.2 ' ' -3.4 ' ' 0.0 ' ' -1.9 ' ' -1.2 ' ' -0.5 '] 并希望找到最小值 如果我执行print min(test)操作,则返回的值为-0.1,这不是最小值(即-3.4) 如何正确返回最小值。首先转换: test.astype(float).min() 先转换: test.astype(float).min() 转换为浮点值?

我有一个numpy.ndarray类型的数组[test]:

[' -0.1 ' ' -0.4 ' ' -0.6 ' ' -0.2 ' ' -3.4 ' ' 0.0 ' ' -1.9 ' ' -1.2 ' ' -0.5 ']
并希望找到最小值

如果我执行
print min(test)
操作,则返回的值为-0.1,这不是最小值(即-3.4)

如何正确返回最小值。

首先转换:

test.astype(float).min()
先转换:

test.astype(float).min()

转换为浮点值?数组中的值似乎是字符串,而不是数字。看看
test.dtype
。我很确定这也是一个字符串列表。。。最小值为-0.1表示字符串,为-3.4表示浮点值转换为浮点值?看起来数组中的值是字符串,而不是数字。看看
test.dtype
。我很确定这也是一个字符串列表。。。最小值为-0.1表示字符串,为-3.4表示浮点数