-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy path2_base_feature.py
39 lines (17 loc) · 1.42 KB
/
2_base_feature.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import pandas as pd
TrainFeature_best_score=pd.read_csv('train_27-29.csv')
TestFeature_best_score=pd.read_csv('test.csv')
print('加入4个时间特征')
TrainFeature_best_score['clickTime_day']=TrainFeature_best_score['clickTime'].apply(lambda x:str(x)[0]+str(x)[1])
TestFeature_best_score['clickTime_day']=TestFeature_best_score['clickTime'].apply(lambda x:str(x)[0]+str(x)[1])
TrainFeature_best_score['clickTime_hour']=TrainFeature_best_score['clickTime'].apply(lambda x:str(x)[2]+str(x)[3])
TestFeature_best_score['clickTime_hour']=TestFeature_best_score['clickTime'].apply(lambda x:str(x)[2]+str(x)[3])
TrainFeature_best_score['clickTime_min']=TrainFeature_best_score['clickTime'].apply(lambda x:str(x)[4]+str(x)[5])
TestFeature_best_score['clickTime_min']=TestFeature_best_score['clickTime'].apply(lambda x:str(x)[4]+str(x)[5])
TrainFeature_best_score['clickTime_second']=TrainFeature_best_score['clickTime'].apply(lambda x:str(x)[6]+str(x)[7])
TestFeature_best_score['clickTime_second']=TestFeature_best_score['clickTime'].apply(lambda x:str(x)[6]+str(x)[7])
print('生成appCategory_pre')
TrainFeature_best_score['appCategory_pre']=TrainFeature_best_score['appCategory'].apply(lambda x:str(x)[0])
TestFeature_best_score['appCategory_pre']=TestFeature_best_score['appCategory'].apply(lambda x:str(x)[0])
TrainFeature_best_score.to_csv('train_27-29.csv',index=False)
TestFeature_best_score.to_csv('test.csv',index=False)