random.sample(population, k)

本文涉及的产品
实时数仓Hologres,5000CU*H 100GB 3个月
检索分析服务 Elasticsearch 版,2核4GB开发者规格 1个月
智能开放搜索 OpenSearch行业算法版,1GB 20LCU 1个月
简介: random.sample(population, k)

random.sample(population, k): 从指定序列中随机选择k个元素作为一个新列表返回

import random
numbers = [1, 2, 3, 4, 5]
selected_numbers = random.sample(numbers, 3)
print(selected_numbers)


相关文章
45Echarts - 柱状图(World Total Population)
45Echarts - 柱状图(World Total Population)
51 0
|
6月前
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
75 0
|
3月前
|
Python
module 'numpy' has no attribute 'int'.
module 'numpy' has no attribute 'int'.
123 0
|
6月前
|
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
|
11月前
|
C++
INT_MIN,max函数和accumulate函数
INT_MIN,max函数和accumulate函数
|
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
515 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
197 0
|
数据可视化
Paraview: Calculate Derivatives of 3-D Unstructured Dataset
关注九天学者微信公众号(扫码关注)第一时间获取技术贴更新! Paraview 是一款基于VTK的、开源的、跨平台的科学数据可视化软件,其三维显示和后处理功能非常强大。
2798 0