pandas.DataFrame.sample
DataFrame.sample(n=None, frac=None, replace=False, weights=None, random_state=None, axis=None)[source]
n : int, optional
Number of items from axis to return. Cannot be used with frac. Default = 1 if frac = None.
frac : float, optional
Fraction of axis items to return. Cannot be used with n.
replace : boolean, optional
Sample with or without replacement. Default = False.
weights : str or ndarray-like, optional
Default ‘None’ results in equal probability weighting. If passed a Series, will align with target object on index. Index values in weights not found in sampled object will be ignored and index values in sampled object not in weights will be assigned weights of zero. If called on a DataFrame, will accept the name of a column when axis = 0. Unless weights are a Series, weights must be same length as axis being sampled. If weights do not sum to 1, they will be normalized to sum to 1. Missing values in the weights column will be treated as zero. inf and -inf values not allowed.
random_state : int or numpy.random.RandomState, optional
Seed for the random number generator (if int), or numpy RandomState object.
axis : int or string, optional
Axis to sample. Accepts axis number or name. Default is stat axis for given data type (0 for Series and DataFrames, 1 for Panels).
Axis参数的意思是,从哪个维度取样。如axis = 0,即从row中取样。
pandas.DataFrame.sample的更多相关文章
- pandas.DataFrame.sample随机抽样
https://study.163.com/course/courseMain.htm?courseId=1006383008&share=2&shareId=400000000398 ...
- Pandas Dataframe增、删、改、查、去重、抽样基本操作
总括 pandas的索引函数主要有三种: loc 标签索引,行和列的名称 iloc 整型索引(绝对位置索引),绝对意义上的几行几列,起始索引为0 ix 是 iloc 和 loc的合体 at是loc的快 ...
- pandas.DataFrame学习系列1——定义及属性
定义: DataFrame是二维的.大小可变的.成分混合的.具有标签化坐标轴(行和列)的表数据结构.基于行和列标签进行计算.可以被看作是为序列对象(Series)提供的类似字典的一个容器,是panda ...
- pandas.DataFrame的pivot()和unstack()实现行转列
示例: 有如下表需要进行行转列: 代码如下: # -*- coding:utf-8 -*- import pandas as pd import MySQLdb from warnings impor ...
- pandas DataFrame apply()函数(1)
之前已经写过pandas DataFrame applymap()函数 还有pandas数组(pandas Series)-(5)apply方法自定义函数 pandas DataFrame 的 app ...
- pandas DataFrame apply()函数(2)
上一篇pandas DataFrame apply()函数(1)说了如何通过apply函数对DataFrame进行转换,得到一个新的DataFrame. 这篇介绍DataFrame apply()函数 ...
- 把pandas dataframe转为list方法
把pandas dataframe转为list方法 先用numpy的 array() 转为ndarray类型,再用tolist()函数转为list
- pandas DataFrame.shift()函数
pandas DataFrame.shift()函数可以把数据移动指定的位数 period参数指定移动的步幅,可以为正为负.axis指定移动的轴,1为行,0为列. eg: 有这样一个DataFrame ...
- pandas DataFrame applymap()函数
pandas DataFrame的 applymap() 函数可以对DataFrame里的每个值进行处理,然后返回一个新的DataFrame: import pandas as pd df = pd. ...
随机推荐
- 继承ConstraintLayout
开发中复杂的布局基本上都可以通过ConstraintLayout实现,所以我们继承ConstraintLayout实现一个EasyConstraintLayout能够为子view添加圆角和阴影效果. ...
- Windows7系统C盘空间不足
C盘要满了,用WizTree发现:;两个大文件, ①睡眠有关的,用命令提示符(管理员身份运行), 命令窗口中输入 powercfg -h off,即可关闭休眠功能,同时 Hiberfil.sys 文件 ...
- vue-lazyload 图片不更新
前几天在用vue写项目的时候,因为图片比较多,所以采用了懒加载插件 vue-lazyload github:https://github.com/hilongjw/vue-lazyload#readm ...
- 1206C Almost Equal
题目大意 给你一个n 让你用1~2*n的数填满一个2*n个点的环 使得任意连续的n个位置的和的最大值减最小值不大于1 分析 我们通过瞎jb找规律发现n为偶数吴姐 而n为奇数我们设前n个位置为0组,后n ...
- 004-URL编码转换函数:escape()、encodeURI()、encodeURIComponent()
一.概述 函数出现时间: escape() javascript 1.0 ...
- uni-app 云打包证书生成笔记
一.android 云打包生成证书 1.jdk和jre安装,配置环境 2.在 C:\Users\Administrator\.android 文件夹下执行:keytool -genkey -alias ...
- FTP 服务器搭建(基于 CentOS 7)
参考资料: 檔案伺服器之三: FTP 伺服器 用 vsftpd 配置FTP服务器 vsftpd 的所有选项 注意,如果要所有人同时编辑 FTP 上的所有文件,可以将 vsftpd.conf 配置文件中 ...
- DS静态查找- 顺序-二分-索引
静态查找 静态表是只执行查找操作,而不执行插入.删除等操作的表. 现在常说的有五大查找方法:顺序查找.分块查找.索引查找.树查找.哈希查找. 后两种之前写过了二叉查找树和哈希表,现在回顾前面三种,它们 ...
- spring-第十一篇之SpEL表达式
1.spring表达式语言,简称SpEL表达式语言
- Java中的I/O
1.Java中的I/O分类 I/O分类: 输入流,输出流,或者字节流,字符流 I/O中的四个抽象基类: InputStream,OutputStream:两者属于字节流,前者输入,后者输出.一般后缀名 ...