Example #1
0
import time
import pandas as pd
import advance,run
app_labels = pd.read_csv(r'data\app_labels.csv')
label_categories= pd.read_csv('data\label_categories.csv')
new_app_lables=run.allAdvance(app_labels)
app_cate={}
new_app_lables = app_labels['genter'].tolist()
for i in new_app_lables:
    app_cate[i] = app_cate.get(i,0) + 1
items=list(app_cate.items())
items.sort(key=lambda x:x[1],reverse=True)
new_app_10_lables=pd.DataFrame(items,columns=['male', 'count'])
print(new_app_10_lables)
# result = pd.merge(new_app_10_lables, label_categories, on='label_id')
# result.to_csv("lable_trans.csv")




Example #2
0
import time
import pandas as pd
import advance, run

phone_brand_device_model = pd.read_csv(r'data\phone_brand_device_model.csv')
events = pd.read_csv(r'data\events.csv')
new_phone_brand_device_model = run.allAdvance(phone_brand_device_model)
events = run.allAdvance(events)
appPingPai_cate = {}
new_app_brand = pd.merge(events, phone_brand_device_model, on='device_id')
new_app_brand = new_app_brand['phone_brand'].tolist()
for i in new_app_brand:
    appPingPai_cate[i] = appPingPai_cate.get(i, 0) + 1
items = list(appPingPai_cate.items())
items.sort(key=lambda x: x[1], reverse=True)
new_app_brand_phone = pd.DataFrame(items[:10], columns=['pingpai', 'count'])
new_app_brand_phone.to_csv("pingpai.csv")
Example #3
0
import time
import pandas as pd
import advance, run
from sklearn.preprocessing import LabelEncoder, OneHotEncoder
phone_brand_device_model = pd.read_csv('data\phone_brand_device_model.csv')
phone_brand_device_model['newColumn'] = phone_brand_device_model[
    'phone_brand'] + phone_brand_device_model['device_model']
advance.drop_col(phone_brand_device_model, ['phone_brand', 'device_model'])
# 使用LabelEncoder将类别转换为数字
model_label_encoder = LabelEncoder()
model_label_encoder.fit(phone_brand_device_model['newColumn'].values)
phone_brand_device_model[
    'brand_model_label_code'] = model_label_encoder.transform(
        phone_brand_device_model['newColumn'].values)
advance.drop_col(phone_brand_device_model, ['newColumn'])
phone_brand_device_model = run.allAdvance(phone_brand_device_model)
phone_brand_device_model.to_csv('new_phone_brand_device_model.csv')