numpy 矩阵拼接

#!/usr/bin/env Python3
# -*- coding: utf-8 -*-
# @Software: PyCharm
# @virtualenv:workon
# @contact: 1040691703@qq.com
# @Desc:Code descripton
__author__ = '未昔/AngelFate'
__date__ = '2020/4/30 18:50'

import numpy as np
a = np.floor(10*np.random.random((2, 2)))
b = np.floor(10*np.random.random((2, 2)))
print (a)
print ('---')
print (b)
print ('---')
print (np.vstack((a, b))) # 按行拼接,也就是竖方向拼接
print ('---')
print (np.hstack((a, b))) # 按列拼接,也就是横方向拼接

[[3. 3.]
 [5. 7.]]
---
[[3. 1.]
 [0. 2.]]
---
[[3. 3.]
 [5. 7.]
 [3. 1.]
 [0. 2.]]
---
[[3. 3. 3. 1.]
 [5. 7. 0. 2.]]

Process finished with exit code 0