GroupBy对象支持迭代操作

grouped1 = df_obj.groupby('key1')
grouped2 = df_obj['data1'].groupby(df_obj['key1'])
1
2
# 单层分组,根据key1
for group_name, group_data in g1:
print(group_name)
print(group_data)
1
2
3
4


# 多层分组,根据key1 和 key2(http://www.amjmh.com/v/BIBRGZ_558768/)
for group_name, group_data in g2:
print(group_name)
print(group_data)
1
2
3
4

---------------------

上一篇:Gaze Estimation学习笔记(1)-Appearance-Based Gaze Estimation in the Wild


下一篇:GroupBy对象可以转换成列表或字典