三維數(shù)組怎么堆疊?
1.最基本的函數(shù):concatenate
np.concatenate((a,b)) # 默認(rèn)axis=0
array([ 0, 1, 2, 10, 11, 12])
2.vstack:垂直連接數(shù)組(axis=0)
np.vstack((a,b))
array([[ 0, 1, 2],
[10, 11, 12]])
3.hstack:水平連接數(shù)組(axis=1)
np.hstack((a,b))
array([ 0, 1, 2, 10, 11, 12])
4.c_[]對象:將向量按列合并
np.c_[a,b,a+b]
array([[ 0, 10, 10],
[ 1, 11, 12],
[ 2, 12, 14]])