Merge two numpy array's of different shape into a single array

后端 未结 2 1960
Happy的楠姐
Happy的楠姐 2021-01-14 00:34

I have two numpy array\'s a and b of length 53 and 82 respectively. I would like to merge them into a single array because I want to use th

2条回答
  •  感动是毒
    2021-01-14 00:44

    You need to use numpy.concatenate instead of array addition

    c = numpy.concatenate((a, b))
    

    Implementation

    import numpy as np
    a = np.arange(53)
    b = np.arange(82)
    c = np.concatenate((a, b))
    

    Output

    c.shape
    (135, )
    

提交回复
热议问题