ValueError: Sample larger than population or is negative

简介: ValueError: Sample larger than population or is negative

选取样本函数random.sample

正确使用示例

# -*- coding: utf-8 -*-
import random
lst = [1, 2, 3]
ret = random.sample(lst, 2)
print(ret)
# [3, 2]

如果选取的数量比全量数据多,就会报错

# -*- coding: utf-8 -*-
import random
lst = [1, 2, 3]
ret = random.sample(lst, 4)
print(ret)
# ValueError: Sample larger than population or is negative
相关文章
|
8月前
GEE错误——Layer error: Image.connectedPixelCount: Segment size calculation on floating point bands is n
GEE错误——Layer error: Image.connectedPixelCount: Segment size calculation on floating point bands is n
86 0
|
8月前
|
Linux Windows
【已解决】ValueError: num_samples should be a positive integer value, but got num_samples=0
【已解决】ValueError: num_samples should be a positive integer value, but got num_samples=0
|
8月前
random.sample(population, k)
random.sample(population, k)
44 0
|
JSON 数据格式
ValueError: With n_samples=0, test_size=0.15 and train_size=None, the resulting train set will be em
ValueError: With n_samples=0, test_size=0.15 and train_size=None, the resulting train set will be em
544 0
ValueError: With n_samples=0, test_size=0.15 and train_size=None, the resulting train set will be em
成功解决ValueError: With n_samples=0, test_size=0.3 and train_size=None, the resulting train set will be
成功解决ValueError: With n_samples=0, test_size=0.3 and train_size=None, the resulting train set will be
成功解决ValueError: With n_samples=0, test_size=0.3 and train_size=None, the resulting train set will be
ValueError: Sample larger than population or is negative
ValueError: Sample larger than population or is negative
205 0
TypeError: can‘t subtract offset-naive and offset-aware datetimes
TypeError: can‘t subtract offset-naive and offset-aware datetimes
124 0
|
数据库
Incorrect result size: expected 1, actual 2
Incorrect result size: expected 1, actual 2
923 0
|
数据可视化
Paraview: Calculate Derivatives of 3-D Unstructured Dataset
关注九天学者微信公众号(扫码关注)第一时间获取技术贴更新! Paraview 是一款基于VTK的、开源的、跨平台的科学数据可视化软件,其三维显示和后处理功能非常强大。
2822 0