How to merge 2 numpy arrays?

后端 未结 3 555
轮回少年
轮回少年 2021-01-25 09:02

I feel like there is some documentation I am missing, but I can\'t find anything on this specific example - everything is just about concatenating or stacking arrays.

I

3条回答
  •  无人及你
    2021-01-25 09:54

    Sounds like the function you're looking for is stack(), using it to stack along the 3rd dimension.

    import numpy as np
    
    x = np.asarray([[1,2,3],[4,5,6]])
    y = np.asarray([[7,8,9],[10,11,12]])
    z = np.stack((x, y), 2)
    

提交回复
热议问题