How to index several 2d numpy arrays with different number of rows in a 3d array?

大兔子大兔子 提交于 2019-12-24 18:25:17

问题


I have the following problem in python: I have several numpy 2d-arrays where all have same number of columns ,but different number of rows.I want to index all these 2d-array in a unique numpy 3d-array where the first index keeps into account each 2d-array. For example : let's suppose I got two 2d-arrays like this : [[1,2,3][4,5,6][7,8,9]] (3X3 array) [[11,12,13][14,15,16]] (2X3 array)

I want to get a numpy 3d-array name,for example, c where : c[0] has shape (3,3), c[1] (2,3) and so on...So I expect a 3d-array whose shape is (number of 2d matrices,number of rows of one matrix,number of columns of one matrix)

How can I reshape since each 2d-arrays have different number of rows each other? Thanks

来源:https://stackoverflow.com/questions/52024847/how-to-index-several-2d-numpy-arrays-with-different-number-of-rows-in-a-3d-array

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!