Python 执行一项;“如有任何真实情况”;检查DataFrame中的布尔列?

Python 执行一项;“如有任何真实情况”;检查DataFrame中的布尔列?,python,pandas,dataframe,boolean,summary,Python,Pandas,Dataframe,Boolean,Summary,我想知道是否有一种方法可以在不遍历DF行的情况下汇总布尔值。我有这样的情况: Label | Attribute Item1 | False Item1 | False Item2 | False Item2 | True Item3 | True Item3 | False 我想这样总结一下: Label | Attribute Item1 | False Item2 | True Item3 | True 用某种“如果有的话是真的”的论点。我已

我想知道是否有一种方法可以在不遍历DF行的情况下汇总布尔值。我有这样的情况:

Label | Attribute  
Item1 | False  
Item1 | False  
Item2 | False  
Item2 | True  
Item3 | True  
Item3 | False  
我想这样总结一下:

Label | Attribute  
Item1 | False  
Item2 | True  
Item3 | True  

用某种“如果有的话是真的”的论点。我已经用groupby&methods(max)等为其他类型的属性编写了一个汇总表,我可以通过迭代创建一个汇总表,但当然,如果有更简单的方法,我宁愿避免。

您也可以使用
descripe()
方法,该方法对于汇总数据帧非常有用

df.groupby('Label')['Attribute'].describe()

尝试使用
df.groupby('Label')['Attribute'].any()
您可以使用
df.set_index('Label').Attribute.any(level=0)
感谢@ChrisA&piRSquared,这些功能非常好!谢谢ChrisA和piRSquared,这些都很好用!