简体   繁体   English

在 Pandas DataFrame python 中访问分组数据的输出

[英]Accesing the output of grouped data in Pandas DataFrame python

I am using the pandas DataFrame groupby feature.Below is a sample code我正在使用 Pandas DataFrame groupby 功能。下面是一个示例代码

df.groupby('type').size()

Output :输出 :

>>> df.groupby('type').size()
type
strongsubj    10
weaksubj       4
dtype: int64

Can you please suggest a way so that I can access the value 10 for the keyword "strongsubj".您能否提出一种方法,以便我可以访问关键字“strongsubj”的值 10。

I am sure there must some easiest way, but I am struggling hard for the same.我相信一定有一些最简单的方法,但我正在为此努力。 Any leads would be appreciable.任何线索都是可观的。

Thanks, Brajen谢谢,布拉金

试试下面-

df.groupby('type').size()['strongsubj']

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM