numpy常用操作之数组拼接

2018-05-18 14:44:14作者: 永永夜来源: [链接]己有:2072人学习过

数组拼接

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.]]


标签(TAG)numpy  

分享到 :

0条评论 添加新评论

后发表评论