Reputation: 129
I have dataframe as below and wanted to filter only column "B" with even numbers.
A B C D
0 9 15 64 28
1 93 29 8 73
2 40 36 16 11
3 88 62 33 72
4 49 51 54 77
Required Output:
A B C D
2 40 36 16 11
3 88 62 33 72
Upvotes: 2
Views: 2140
Reputation: 71600
Just use modulo math like the below:
df[df['B'] % 2 == 0]
And now printing df
would give the expected dataframe.
Upvotes: 2