当前位置:网站首页>Valueerror: cannot take a larger sample than population when 'replace=false‘
Valueerror: cannot take a larger sample than population when 'replace=false‘
2022-06-24 22:17:00 【Dai Meng Ma】
Complete error report
ValueError: Cannot take a larger sample than population when 'replace=False'
resolvent
An error will be reported when the number of target samples is greater than the existing samples , You need to make your own judgment based on your business , For example, the following is a solution
import pandas as pd
import numpy as np
dataframe = pd.DataFrame(np.random.random(size=(10, 2)))
# Start sampling
sample_df = dataframe.sample(20) if dataframe.shape[0] > 20 else dataframe # If the number of samples exceeds some samples , Just go back , Otherwise, only return to 20 individual
print(sample_df.shape)
sample_df = dataframe.sample(6) if dataframe.shape[0] > 6 else dataframe
print(sample_df.shape)
Problem analysis
Using the following code will result in an error :
import pandas as pd
import numpy as np
dataframe = pd.DataFrame(np.random.random(size=(10, 2)))
dataframe.sample(20)
边栏推荐
- [notes of Wu Enda] multivariable linear regression
- 华大04a工作模式/低功耗模式
- 性能测试工具wrk安装使用详解
- 排查到解决问题的过程:浏览器突然无法访问网页,错误代码:0x80004005,最终定位:“电脑打开热点,电脑就不能上网了”
- 985 test engineer is hanged. Who is more important in terms of education and experience?
- Collective search + drawing creation
- leetcode:55. Jumping game [classic greed]
- 虚拟人的产业发展现状
- Drag drag drag
- Servlet details
猜你喜欢

leetcode-201_ 2021_ 10_ seventeen

想当测试Leader,这6项技能你会吗?

Description of software version selection of kt6368a Bluetooth dual-mode transparent chip

first-order-model实现照片动起来(附工具代码) | 机器学习

985测试工程师被吊打,学历和经验到底谁更重要?

Detailed installation and use of performance test tool wrk

Raspberry pie preliminary use

First order model realizes photo moving (with tool code) | machine learning

How to extract dates from web pages?

leetcode:515. 在每个树行中找最大值【无脑bfs】
随机推荐
TCP RTT测量妙计
华大04a工作模式/低功耗模式
[untitled]
壹沓科技签约七匹狼,助力「中国男装领导者」数字化转型
学习笔记23--多传感器信息融合基础理论(上)
如何抓手机的包进行分析,Fiddler神器或许能帮到您!
TCP RTT measurement tips
[notes of Wu Enda] multivariable linear regression
How to grab the mobile phone bag for analysis? Fiddler artifact may help you!
Flutter 库冲突问题解决
好想送对象一束花呀
SAP interface debug setting external breakpoints
Collapse code using region
KT6368A蓝牙双模透传芯片软件版本选型说明
Binary search tree template
leetcode1863_ 2021-10-14
Flutter: Unsupported value: false/true
ansible基本配置
In the first year of L2, arbitrum nitro was upgraded to bring more compatible and efficient development experience
Find the maximum value in each tree row [extension of one of the hierarchical traversals]