且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将列表转换为numpy数组

更新时间:2022-12-13 17:51:49

如果有列表列表,则只需要使用...

If you have a list of lists, you only needed to use ...

import numpy as np
...
npa = np.asarray(someListOfLists, dtype=np.float32)

为此 LINK /numpy文档中的strong> .您只需要在对asarray的调用中定义dtype.

per this LINK in the scipy / numpy documentation. You just needed to define dtype inside the call to asarray.