Skip to content

Latest commit

 

History

History
19 lines (15 loc) · 447 Bytes

80.md

File metadata and controls

19 lines (15 loc) · 447 Bytes
@author jackzhenguo
@desc 
@date 2019/5/1

80 sample 样本抽样

使用sample抽样,如下例子从100个样本中随机抽样10个。

from random import randint,sample
lst = [randint(0,50) for _ in range(100)]
print(lst[:5])# [38, 19, 11, 3, 6]
lst_sample = sample(lst,10)
print(lst_sample) # [33, 40, 35, 49, 24, 15, 48, 29, 37, 24]
[上一个例子](79.md) [下一个例子](81.md)