def hstack(tup):
"""
Stack arrays in sequence horizontally (column wise).
This is equivalent to concatenation along the second axis, except for 1-D
arrays where it concatenates along the first axis. Rebuilds arrays divided
by `hsplit`.
This function makes most sense for arrays with up to 3 dimensions. For
instance, for pixel-data with a height (first axis), width (second axis),
and r/g/b channels (third axis). The functions `concatenate`, `stack` and
`block` provide more general stacking and concatenation operations.
水平顺序堆叠数组(按列)。 这相当于沿第二个轴连接,除了沿第一个轴连接的一维数组。 重建除以 `hsplit` 的数组。 此函数对最多 3 维的数组最有意义。 例如,对于具有高度(第一轴)、宽度(第二轴)和 r 的像素数据
Parameters
----------
tup : sequence of ndarrays
The arrays must have the same shape along all but the second axis,
except 1-D arrays which can be any length.
Returns
-------
stacked : ndarray
The array formed by stacking the given arrays.
See Also
--------
concatenate : Join a sequence of arrays along an existing axis.
stack : Join a sequence of arrays along a new axis.
block : Assemble an nd-array from nested lists of blocks.
vstack : Stack arrays in sequence vertically (row wise).
dstack : Stack arrays in sequence depth wise (along third axis).
column_stack : Stack 1-D arrays as columns into a 2-D array.
hsplit : Split an array into multiple sub-arrays horizontally (column-wise).
参数 ? ? ?---------- ? ? ?tup : ndarrays 序列 ? ? ? ? ?除了第二个轴之外,阵列必须具有相同的形状, ? ? ? ? ?除了可以是任意长度的一维数组。
? ? ?退货 ? ? ?-------- ? ? ?堆叠:ndarray ? ? ? ? ?通过堆叠给定数组形成的数组。
? ? ?也可以看看 ? ? ?-------- ? ? ?concatenate :沿现有轴连接一系列数组。 ? ? ?stack :沿新轴加入一系列数组。 ? ? ?block :从嵌套的块列表中组装一个 nd 数组。 ? ? ?vstack :垂直(按行)按顺序堆叠数组。 ? ? ?dstack :按顺序深度(沿第三轴)堆叠数组。 ? ? ?column_stack :将一维数组作为列堆叠到二维数组中。 ? ? ?hsplit :将一个数组水平拆分为多个子数组(按列)。
Examples
--------
>>> a = np.array((1,2,3))
>>> b = np.array((4,5,6))
>>> np.hstack((a,b))
array([1, 2, 3, 4, 5, 6])
>>> a = np.array([[1],[2],[3]])
>>> b = np.array([[4],[5],[6]])
>>> np.hstack((a,b))
array([[1, 4],
[2, 5],
[3, 6]])
vstack是垂直堆叠
np.vstack((a,b))
array([[1],
[2],
[3],
[4],
[5],
[6]])
|