import numpy as np
x = np.array(['1.1', '2.2', '3.3'])
y = x.astype(np.float)
如果遇到: ValueError: Can only create a chararray from string data.
x=[float(n) for n in x]
x=np.array(x)
import numpy as np
x = np.array(['1.1', '2.2', '3.3'])
y = x.astype(np.float)
如果遇到: ValueError: Can only create a chararray from string data.
x=[float(n) for n in x]
x=np.array(x)
本文标题:python : array str to float
本文链接:https://www.haomeiwen.com/subject/mgqcgctx.html
网友评论