Concatenation of 2 1D `numpy` Arrays Along 2nd Axis

前端 未结 5 1111
不知归路
不知归路 2021-02-18 22:59

Executing

import numpy as np
t1 = np.arange(1,10)
t2 = np.arange(11,20)

t3 = np.concatenate((t1,t2),axis=1)

results in a

Trac         


        
5条回答
  •  春和景丽
    2021-02-18 23:03

    This is because you need to change it into two dimensions because one dimesion cannot concatenate with. By doing this you can add an empty column. It works if you run the following code:

    import numpy as np 
    t1 = np.arange(1,10)[None,:]
    t2 = np.arange(11,20)[None,:]
    t3 = np.concatenate((t1,t2),axis=1)
    print(t3)
    

提交回复
热议问题