Pythonic way to create a numpy array from a list of numpy arrays

后端 未结 6 1073
执笔经年
执笔经年 2020-12-13 06:24

I generate a list of one dimensional numpy arrays in a loop and later convert this list to a 2d numpy array. I would\'ve preallocated a 2d numpy array if i knew the number o

6条回答
  •  無奈伤痛
    2020-12-13 06:55

    Even simpler than @Gill Bates' answer, here is an one line code:

    np.stack(list_of_arrays, axis=0)
    

提交回复
热议问题