0

I have a DataFrame like that:

index A B C
0     1 0 2
1     0 0 3
2     0 1 5
3     0 2 1
4     1 2 2
5     0 2 5

And I need to get only the rows that contains number 1, but the number 1 can be in any column in df.

Ex:

index A B C
0     1 0 2
2     0 1 5
3     0 2 1
4     1 2 2

1 Answers1

1

Check

df = df[df.eq(1).any(axis=1)]
BENY
  • 317,841
  • 20
  • 164
  • 234