我就写一下我遇到的,更多具体的请看Python之Numpy数组拼接,组合,连接
>>> a
array([0, 1, 2],
[3, 4, 5],
[6, 7, 8])
>>> b = a*2
>>> b
array([ 0, 2, 4],
[ 6, 8, 10],
[12, 14, 16])
1.水平组合
>>> np.hstack((a,b))
array([ 0, 1, 2, 0, 2, 4],
[ 3, 4, 5, 6, 8, 10],
[ 6, 7, 8, 12, 14, 16])
>>> np.concatenate((a,b),axis=1)
array([ 0, 1, 2, 0, 2, 4],
[ 3, 4, 5, 6, 8, 10],
[ 6, 7, 8, 12, 14, 16])
2.垂直组合
>>> np.vstack((a,b))
array([ 0, 1, 2],
[ 3, 4, 5],
[ 6, 7, 8],
[ 0, 2, 4],
[ 6, 8, 10],
[12, 14, 16])
>>> np.concatenate((a,b),axis=0)
array([ 0, 1, 2],
[ 3, 4, 5],
[ 6, 7, 8],
[ 0, 2, 4],
[ 6, 8, 10],
[12, 14, 16])