Skip to content Skip to sidebar Skip to footer

Python Pandas Select Group Where A Specific Column Contains Zeroes

I'm working on a small project using Python Pandas and I'm stuck at the following problem: I have a table where column A contains multiple and possibly non unique values and a seco

Solution 1:

One way is to get all values of column A where column B is zero, and then group on this filtered set.

groups = df[df['Column B'] == 0]['Column A'].unique()
>>> df[df['Column A'].isin(groups)]
  Column A  Column B
2        f         0
5        f        10

Post a Comment for "Python Pandas Select Group Where A Specific Column Contains Zeroes"