python numpy hstack() from shape_base.py (将数组水平堆叠)

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`.
    这等效于沿第二个轴的串联,除了一维数组沿第一个轴的串联。 重建除以“ 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.
    此功能对最多3维的阵列最有意义。 
    例如,对于具有高度(第一轴),宽度(第二轴)和r / g / b通道(第三轴)的像素数据。 
    函数concatenate,stack和block提供了更常规的堆叠和串联操作。

    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.
        ndarray的序列
         除第二个轴外,所有阵列的形状都必须相同,除了一维阵列可以是任意长度。

    Returns
    -------
    stacked : ndarray
        The array formed by stacking the given arrays.
    堆叠:ndarray
         通过堆叠给定数组形成的数组。

    See Also
    --------
    stack : Join a sequence of arrays along a new axis.
    		沿新轴连接一系列数组。
    vstack : Stack arrays in sequence vertically (row wise).
    		 垂直(行)按顺序堆叠数组。
    dstack : Stack arrays in sequence depth wise (along third axis).
    		 沿深度方向(沿第三轴)按顺序堆叠数组。
    concatenate : Join a sequence of arrays along an existing axis.
    			  沿现有轴连接一系列数组。
    hsplit : Split array along second axis.
    		 沿第二个轴拆分数组。
    block : Assemble arrays from blocks.
    		从块组装数组。

    Examples
    --------
    >>> a = np.array((1,2,3))
    >>> b = np.array((2,3,4))
    >>> np.hstack((a,b))
    array([1, 2, 3, 2, 3, 4])
    >>> a = np.array([[1],[2],[3]])
    >>> b = np.array([[2],[3],[4]])
    >>> np.hstack((a,b))
    array([[1, 2],
           [2, 3],
           [3, 4]])

    """
    arrs = [atleast_1d(_m) for _m in tup]
    # As a special case, dimension 0 of 1-dimensional arrays is "horizontal"
    if arrs and arrs[0].ndim == 1:
        return _nx.concatenate(arrs, 0)
    else:
        return _nx.concatenate(arrs, 1)

你可能感兴趣的:(Python)