sampling
import xlrd, xlwt, time, random
xl = xlrd.open_workbook(r'C:\Users\Administrator\Desktop\分层抽样...补充拓展:pandas实现对dataframe抽样的实现
随机抽样
import pandas as pd
#对dataframe随机抽取2000个样本
pd.sample(df, n=2000)
分层抽样...是在X中的某一个属性列
X_train, X_test, y_train, y_test = train_test_split(X,y, test_size=0.2, stratify=y)
以上这篇python