python : array str to float
2019-12-03 本文已影响0人
夏天不热也不冷
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)