Force numpy to create array of objects

后端 未结 4 1612
终归单人心
终归单人心 2020-11-30 13:08

I have an array:

x = np.array([[1, 2, 3], [4, 5, 6]])

and I want to create another array of shape=(1, 1) and dtype=np.ob

4条回答
  •  执念已碎
    2020-11-30 13:40

    Found a solution myself:

    a=np.zeros(shape=(2, 2), dtype=np.object)
    a[:] = [[x, x], [x, x]]
    

提交回复
热议问题