How to initialize Numpy array of list objects

前端 未结 1 834
滥情空心
滥情空心 2021-01-20 04:42

I\'m trying to create a numpy array that looks like

array([[list([]), list([])],
       [list([]), list([])],
       [list([]), list([])]], dtype=object)


        
相关标签:
1条回答
  • 2021-01-20 05:10

    You could use the following:

    np.frompyfunc(list, 0, 1)(np.empty((3,2), dtype=object))  
    

    We first turn list into a ufunc that takes no arguments and returns a single empty list, then apply it to an empty 3x2 array of object type.

    0 讨论(0)
提交回复
热议问题