def load_BCPair_action_cnt(start_date = '2016-02-01 00:00:00', end_date = '2016-04-16 00:00:00', actions=[1,2,3,4,5,6]):
'''
????-??????
'''
dump_path = './cache/BCPair_action_cnt_{0}_{1}.pkl'.format(start_date[:10], end_date[:10])
if os.path.exists(dump_path):
with open(dump_path, 'rb') as f:
df = pickle.load(f)
else:
df = get_action_data(start_date = start_date, end_date = end_date, field=['brand', 'cate', 'type'])
prefix = 'BCPair_action_cnt_{0}_{1}'.format(start_date[:10], end_date[:10])
type_dummies = pd.get_dummies(df.type, prefix=prefix)
df = pd.concat([df.drop(['type'], axis=1), type_dummies], axis=1)
df = df.groupby(['brand', 'cate'], as_index=False).sum()
with open(dump_path, 'wb') as f:
pickle.dump(df, f)
rt_cols = ['brand', 'cate']
rt_cols.extend(['BCPair_action_cnt_{0}_{1}_{2}'.format(start_date[:10], end_date[:10], i) for i in actions])
df = df[rt_cols]
return df
features_generator.py 文件源码
python
阅读 24
收藏 0
点赞 0
评论 0
评论列表
文章目录