首页 > 代码库 > vstack & hstack & concatenate

vstack & hstack & concatenate

 1 In[86]: a,b 2 Out[86]: (array([1, 2, 3]), array([4, 5, 6])) 3 In[87]: np.concatenate((a,b),axis=0) 4 Out[87]: array([1, 2, 3, 4, 5, 6]) 5 In[88]: np.concatenate((a,b),axis=1) 6 Out[88]: array([1, 2, 3, 4, 5, 6]) 7 In[89]: np.vstack((a,b)) 8 Out[89]:  9 array([[1, 2, 3],10        [4, 5, 6]])11 In[90]: np.hstack((a,b))12 Out[90]: array([1, 2, 3, 4, 5, 6])13 In[93]: a114 Out[93]: 15 array([[1, 2, 3],16        [4, 5, 6]])17 In[94]: a218 Out[94]: 19 array([[ 7,  8,  9],20        [10, 11, 12]])21 In[95]: np.concatenate((a1,a2),axis=0)22 Out[95]: 23 array([[ 1,  2,  3],24        [ 4,  5,  6],25        [ 7,  8,  9],26        [10, 11, 12]])27 In[96]: np.concatenate((a1,a2),axis=1)28 Out[96]: 29 array([[ 1,  2,  3,  7,  8,  9],30        [ 4,  5,  6, 10, 11, 12]])31 In[97]: np.vstack((a1,a2))32 Out[97]: 33 array([[ 1,  2,  3],34        [ 4,  5,  6],35        [ 7,  8,  9],36        [10, 11, 12]])37 In[98]: np.hstack((a1,a2))38 Out[98]: 39 array([[ 1,  2,  3,  7,  8,  9],40        [ 4,  5,  6, 10, 11, 12]])

 

vstack & hstack & concatenate