应用groupby后从网上论坛中获取特定元素-PANDAS [英] Get specific element from Groups after applying groupby - PANDAS
本文介绍了应用groupby后从网上论坛中获取特定元素-PANDAS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我通过以下方式将一个数据帧中的总和数据分组:
I have grouped sum data in a dataframe, by the following:
groups = df.groupby(['name'])
现在,我可以通过groups.head(2)来获得组的头,它给出了前两行.
Now I can get the head of the groups by groups.head(2) which gives the first two rows.
但是如何获得一个具有特定名称的群组?即,如果我要使用组名称为"ruby"的单个组,则不能只做group ['ruby']
But how do I get a group by a specific name? i.e. if I want the single group where the group name is 'ruby', I can't just do groups['ruby']
推荐答案
怎么样:
groups.get_group('name')
有关详细说明,请查看此相关问题
这篇关于应用groupby后从网上论坛中获取特定元素-PANDAS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文