数据预处理

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

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值