分组聚合

import pandas as pd
#
a = [
{"name": 'tom', "age": '18'},
{"name": "jack", "age": "42"},
{"name": "lily", "age": "18"}]

df = pd.DataFrame(sccode_list)

res = [{"key":list(k),"rc_code":g["rc_code"].tolist()} for k, g in df.groupby(['appid','service_code','service_name'])]
#
print(res)
posted @ 2020-05-04 21:39  zhang.ning  阅读(219)  评论(0编辑  收藏  举报