pandas groupby 分组的操作

groupby有点类似于sql,可以分组统计 (和,平均值,计数) 等等

1. 求和。这是根据name汇总求和,并且重新设立index

	data_groupby_app = data.groupby(['NAME']).sum().reset_index()

2. 计数

这句话将数个字段汇总,即不同关键字段的排列组合汇总,做计数功能

	all_num  = result_detail[['sn','i_factory','algVer','screen']].groupby(['i_factory','algVer','screen']).agg('count').reset_index()       

3. 平均,与上同

    user_success_t = result_success.groupby(['home','hobby']).mean().reset_index()

猜你喜欢

转载自blog.csdn.net/endif6/article/details/81479963