python numpy hstack() from shape_base.py (将数组水平堆叠)
生活随笔
收集整理的這篇文章主要介紹了
python numpy hstack() from shape_base.py (将数组水平堆叠)
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
def hstack(tup):"""Stack arrays in sequence horizontally (column wise).水平(按列)順序堆疊數(shù)組。This is equivalent to concatenation along the second axis, except for 1-Darrays where it concatenates along the first axis. Rebuilds arrays dividedby `hsplit`.這等效于沿第二個軸的串聯(lián),除了一維數(shù)組沿第一個軸的串聯(lián)。 重建除以“ hsplit”的數(shù)組。This function makes most sense for arrays with up to 3 dimensions. Forinstance, 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通道(第三軸)的像素數(shù)據(jù)。 函數(shù)concatenate,stack和block提供了更常規(guī)的堆疊和串聯(lián)操作。Parameters----------tup : sequence of ndarraysThe arrays must have the same shape along all but the second axis,except 1-D arrays which can be any length.ndarray的序列除第二個軸外,所有陣列的形狀都必須相同,除了一維陣列可以是任意長度。Returns-------stacked : ndarrayThe array formed by stacking the given arrays.堆疊:ndarray通過堆疊給定數(shù)組形成的數(shù)組。See Also--------stack : Join a sequence of arrays along a new axis.沿新軸連接一系列數(shù)組。vstack : Stack arrays in sequence vertically (row wise).垂直(行)按順序堆疊數(shù)組。dstack : Stack arrays in sequence depth wise (along third axis).沿深度方向(沿第三軸)按順序堆疊數(shù)組。concatenate : Join a sequence of arrays along an existing axis.沿現(xiàn)有軸連接一系列數(shù)組。hsplit : Split array along second axis.沿第二個軸拆分?jǐn)?shù)組。block : Assemble arrays from blocks.從塊組裝數(shù)組。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)
總結(jié)
以上是生活随笔為你收集整理的python numpy hstack() from shape_base.py (将数组水平堆叠)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: opencv python matplo
- 下一篇: Intel Realsense D435