How to save a list as numpy array in python?

前端 未结 9 929
心在旅途
心在旅途 2020-12-04 08:27

Is possible to construct a NumPy array from a python list?

9条回答
  •  没有蜡笔的小新
    2020-12-04 08:47

    I suppose, you mean converting a list into a numpy array? Then,

    import numpy as np
    
    # b is some list, then ...    
    a = np.array(b).reshape(lengthDim0, lengthDim1);
    

    gives you a as an array of list b in the shape given in reshape.

提交回复
热议问题