1.数据离散化
import pandas
hour_cut =[-1,8,16,23]
hour_name = ['1','2','3']
Train_oper['time_hour_cut'] = pd.cut(Train_oper['time_hour'],hour_cut,labels = hour_name)
Train_oper['time_hour_cut'].value_counts()
2.重置索引
import pandas as pd
df.reset_index(drop =True)
3.goupby处理索引
df.groupby(['x1,x2'],as_index = True).agg({'x3':['max','min','mean']})
4. sklearn随机产生数据集
#sklearn随机产生数据集
from sklearn.datasets.samples_generator import make_classification
X,labels=make_classification(n_samples=1000,n_features=5,n_redundant=0,n_informative=2,
random_state=1,n_clusters_per_class=2)
df = pd.DataFrame(X)
df.columns =['x1','x2','x3','x4','x5']
df['target'] = labels