你的情况groupby
与all
df.groupby('Col1').Col2.all().loc[lambda x : x ].index.tolist()
Out[350]: ['A', 'C']
有无 groupby
df.loc[~df.Col1.isin(df.Col1[df.Col2.eq(0)]),'Col1'].unique()
Out[352]: array(['A', 'C'], dtype=object)
从评论
cs95:df.loc[df['Col2'].astype(bool).groupby(df['Col1']).transform('all'), 'Col1'].unique()
df.loc[df['Col2'].astype(bool).groupby(df['Col1']).transform('all'), 'Col1'].unique()
[*{*df.Col1[df.Col2.eq(1).groupby(df.Col1).transform(all)]}]
@WeNYoBen:我使用了第一个解决方案,并且有效。我没有尝试其他解决方案,但是无论如何我都会对其进行标记。谢谢!