给出示例数据, xx ,yy:
import numpy as np
xx=np.array([[1,2,4],
[12,3,4]])
yy=np.array([2,3,10,12,3,1])
>>> xx.ravel().shape,yy.shape
((6,), (6,))
np.raval( ): 将矩阵按行拉平
>>> xx.ravel()
array([1,2,3,4,12,3,4])
np.c_[ ]: 按列(column)拼接n个矩阵
>>> np.c_[xx,xx]
array([[ 1, 2, 4, 1, 2, 4],
[12, 3, 4, 12, 3, 4]])
>>> np.c_[(xx.ravel(),yy]
array([1, 2],
[2, 3],
[4, 10],
[12,12],
[3, 3],
[4, 1])
np.r_[ ]: 按行(row)拼接n个矩阵
>>> np.r_[xx.ravel(),yy], np.r_[xx.ravel(),yy].shape
(array([ 1, 2, 4, 12, 3, 4, 2, 3, 10, 12, 3, 1]),
(12,))