用法:
dask.bag.random.choices(population, k=1)
返回一個 k 大小的替換元素列表。
- population: Bag:
要采樣的元素。
- k: integer, optional:
要采樣的元素數。
參數:
例子:
>>> import dask.bag as db >>> from dask.bag import random >>> b = db.from_sequence(range(5), npartitions=2) >>> list(random.choices(b, 3).compute()) [1, 1, 5]
相關用法
- Python dask.bag.random.sample用法及代碼示例
- Python dask.bag.range用法及代碼示例
- Python dask.bag.read_text用法及代碼示例
- Python dask.bag.Bag.frequencies用法及代碼示例
- Python dask.bag.Bag.to_textfiles用法及代碼示例
- Python dask.bag.Bag.repartition用法及代碼示例
- Python dask.bag.Bag.join用法及代碼示例
- Python dask.bag.Bag.accumulate用法及代碼示例
- Python dask.bag.Bag.fold用法及代碼示例
- Python dask.bag.Bag.map_partitions用法及代碼示例
- Python dask.bag.Bag.groupby用法及代碼示例
- Python dask.bag.map用法及代碼示例
- Python dask.bag.Bag.reduction用法及代碼示例
- Python dask.bag.Bag.foldby用法及代碼示例
- Python dask.bag.Bag.flatten用法及代碼示例
- Python dask.bag.from_sequence用法及代碼示例
- Python dask.bag.Bag.remove用法及代碼示例
- Python dask.bag.Bag.random_sample用法及代碼示例
- Python dask.bag.Item.visualize用法及代碼示例
- Python dask.bag.Bag.distinct用法及代碼示例
注:本文由純淨天空篩選整理自dask.org大神的英文原創作品 dask.bag.random.choices。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。