numpy.concatenate()的官方语法是
numpy.concatenate((a1,a2,...),axis = 0,out = None,dtype = None,cast =“ same_kind”
对out的要求是
out ndarray,可选
如果提供,则为放置结果的目的地。形状必须正确,并且与未指定out参数的串联连接的形状匹配。
举例
array01=np.arange(24).reshape(4,6)
array01
结果
array([[ 0, 1, 2, 3, 4, 5],
[ 6, 7, 8, 9, 10, 11],
[12, 13, 14, 15, 16, 17],
[18, 19, 20, 21, 22, 23]])
array04 = np.ones((4,15),dtype='int32')
array04
结果
array([[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]])
np.concatenate((array01,array03),axis=1,out=array04)
结果
array([[ 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 6, 7, 8],
[ 6, 7, 8, 9, 10, 11, 9, 10, 11, 12, 13, 14, 15, 16, 17],
[12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26],
[18, 19, 20, 21, 22, 23, 27, 28, 29, 30, 31, 32, 33, 34, 35]])