数组拼接
A = np.floor(np.random.randn(2,3) * 10)print 'A:\n', A
B = np.floor(np.random.randn(2,3) * 10)print 'B:\n', B1234
A:
[[ -2. 3. -10.]
[ 5. 4. 7.]]
B:
[[-14. -7. 3.]
[ 10. 6. -8.]]1234567
# 按第一个轴拼接print '按行拼接:'print np.vstack([A,B])# 按第二个轴拼接print '按列拼接:'print np.hstack([A,B])123456
按行拼接:
[[ -2. 3. -10.]
[ 5. 4. 7.]
[-14. -7. 3.]
[ 10. 6. -8.]]
按列拼接:
[[ -2. 3. -10. -14. -7. 3.]
[ 5. 4. 7. 10. 6. -8.]]
0条评论 添加新评论