how to convert 2d list to 2d numpy array?

后端 未结 4 1196
醉酒成梦
醉酒成梦 2020-12-22 23:28

I have a 2D list something like

a = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] 

and I want to convert it to a 2d numpy array. Can we do it without

4条回答
  •  时光说笑
    2020-12-22 23:53

    I am using large data sets exported to a python file in the form

    XVals1 = [.........] 
    XVals2 = [.........] 
    

    Each list is of identical length. I use

    >>> a1 = np.array(SV.XVals1)
    
    >>> a2 = np.array(SV.XVals2)
    

    Then

    >>> A = np.matrix([a1,a2])
    

提交回复
热议问题