目标函数

故事扮演 提交于 2019-11-29 08:18:56
import pandas as pd
import glob
data_dir = './data/'
file_paths = glob.glob(data_dir + '*.zip')
file_paths = sorted(file_paths)
df_list = []

print(len(file_paths))
for path in file_paths[-4:]:
    df_list.append(pd.read_csv(path, 
            names = ['index', 'player_id', 'giftID', 'state', 'offer_time'], 
            sep = ',', compression='zip', quotechar='"'))
log = pd.concat(df_list)
del df_list
log = log[log['giftID'].isin(exchange['charge_id'])]
print(log.shape)
import json
def parse_log(log):
    feature = log[['index', 'player_id', 'giftID', 'offer_time']]
    feature_dict = dict()
    keys = json.loads(log['state'].iloc[0]).keys()
    for key in keys:
        feature_dict[key] = []
    for line in log['state']:
        data = json.loads(line)
        for key in keys:
            feature_dict[key].append(data[key])
    
    for key in keys:
        feature[key] = feature_dict[key]
        
    return feature
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!