感觉numpy.hstack()和numpy.column_stack()函数略有相似,numpy.vstack()与numpy.row_stack()函数也是挺像的。
给一个相关函数的列表:
stack() Join a sequence of arrays along a new axis.
hstack() Stack arrays in sequence horizontally (column wise).
dstack() Stack arrays in sequence depth wise (along third dimension).
concatenate() Join a sequence of arrays along an existing axis.
vsplit () Split array into a list of multiple sub-arrays vertically.
一、numpy.stack()函数
函数原型:numpy.stack(arrays, axis=0)
程序实例:
>>> arrays = [np.random.randn(3, 4) for _ in range(10)]
>>> np.stack(arrays, axis=0).shape
(10, 3, 4)
>>>
>>> np.stack(arrays, axis=1).shape
(3, 10, 4)
>>>
>>> np.stack(arrays, axis=2).shape
(3, 4, 10)
>