简体   繁体   English

一维numpy数组浮动

[英]1D numpy array to float

I want to convert a 1D numpy array to a simple float (no array). 我想将一维numpy数组转换为简单的float(无数组)。 How is that done? 怎么做? Here is my current code with the variable 'acc'. 这是我当前的变量为'acc'的代码。

print type(acc)
print acc.shape

>>> <type 'numpy.ndarray'>
>>> (1,)

Can't you just do: 你不能只是做:

float(acc)

To make it a float? 要使其漂浮? Seems to be working here: 似乎在这里工作:

a = np.array([1])
print a.shape
print type(a)
print float(a)

yields 产量

(1,)
<type 'numpy.ndarray'>
1.0

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM