Udd*_*ain 5 python arrays string numpy python-3.x
我有一个字符串格式的数字列表。我使用 将该列表转换为 numpy 数组np.asarray()
。
如何将字符串元素转换为整数?
小智 3
如果你有x = np.matrix
, 其中每个元素都是 '1.0' (as str
) 并且你想将其转换为int
or float
:
x = x.astype(np.float)
Run Code Online (Sandbox Code Playgroud)