groupby的时候直接简单分组会发现数据不是平铺的:
#天的数据累加
def sum_day(data_01_07):
FIELDS_GROUP_BY=['account_id','plan_id']
data_01_07=data_01_07[['account_id', 'plan_id', 'cost','leave_phone_num','clue_num','distribute_num','see_num','subscribe_num']].groupby(FIELDS_GROUP_BY).sum()
data_01_07.index.rename(FIELDS_GROUP_BY, inplace=True)
data_01_07.reset_index(inplace=True)
return data_01_07
sum_day_re=sum_day(wd2_5)
#小时的数据分组聚合
def sum_hour(data_01_07_h):
FIELDS_GROUP_BY=['account_id','plan_id','ct_h']
data_01_07_h=data_01_07_h.groupby(FIELDS_GROUP_BY).agg({