首页IT科技python中sample的用法(python中Sample函数是什么?)

python中sample的用法(python中Sample函数是什么?)

时间2025-05-04 10:56:46分类IT科技浏览6055
导读:本文教程操作环境:windows7系统、Python 3.9.1,DELL G3电脑。...

本文教程操作环境:windows7系统            、Python 3.9.1                ,DELL G3电脑                。

python中Sample函数

1                       、在Pandas中进行数据分析                   ,能够随机选取若干个行或列       ,做列表的抽取;

2       、函数参数有:frac         、replace                      、weights           、random_state和axis                   。

函数作用:

随机选取若干个行或列       。

函数用法:

DataFrame.sample(n=None,frac=None,replace=False,weights=None,random_state=None,axis=None)

函数参数:

frac      、replace                     、weights               、random_state   、axis

实例演示:

随机抽取5行            。

sample1=df.sample(n=5) sample1

输出结果:

创心域SEO版权声明:以上内容作者已申请原创保护,未经允许不得转载,侵权必究!授权事宜、对本内容有异议或投诉,敬请联系网站管理员,我们将尽快回复您,谢谢合作!

展开全文READ MORE
python glob2(python中glob库是什么?) 跑车代金券(Namecheap优惠码二月更新汇总 .in域名转移仅需6.58美元(namecheap优惠券))