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

前端 未结 5 1187
不知归路
不知归路 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:24

    If you need an array with two columns you can use column_stack:

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

    Which results

    [[ 1 11]
     [ 2 12]
     [ 3 13]
     [ 4 14]
     [ 5 15]
     [ 6 16]
     [ 7 17]
     [ 8 18]
     [ 9 19]]
    

提交回复
热议问题