當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Python dask.array.repeat用法及代碼示例

用法:

dask.array.repeat(a, repeats, axis=None)

重複數組的元素。

此文檔字符串是從 numpy.repeat 複製的。

可能存在與 Dask 版本的一些不一致之處。

參數

aarray_like

輸入數組。

repeats整數或整數數組

每個元素的重複次數。 repeats 被廣播以適應給定軸的形狀。

axis整數,可選

沿其重複值的軸。默認情況下,使用扁平化的輸入數組,並返回一個扁平的輸出數組。

返回

repeated_arrayndarray

a 具有相同形狀的輸出數組,除了沿給定軸。

例子

>>> np.repeat(3, 4)  
array([3, 3, 3, 3])
>>> x = np.array([[1,2],[3,4]])  
>>> np.repeat(x, 2)  
array([1, 1, 2, 2, 3, 3, 4, 4])
>>> np.repeat(x, 3, axis=1)  
array([[1, 1, 1, 2, 2, 2],
       [3, 3, 3, 4, 4, 4]])
>>> np.repeat(x, [1, 2], axis=0)  
array([[1, 2],
       [3, 4],
       [3, 4]])

相關用法


注:本文由純淨天空篩選整理自dask.org大神的英文原創作品 dask.array.repeat。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。