1

I have a sparse dataframe with a lot of '0's. There are totally 3 columns. How can I delete the rows that contain two '0's or more. For example:

df = pd.DataFrame({'a': [0, 1, 2, 3], 'b': [0, 0, 5, 7], 'c': [0, 0, 0, 0]})

df =
     a    b    c
0    0    0    0
1    1    0    0
2    2    5    0
3    3    7    0

The result should be:

df =
         a    b    c
    0    2    5    0
    1    3    7    0
Ting Wang
  • 221
  • 3
  • 13
  • 2
    Add a `.reset_index(drop=True)` to either of the answers to get your exact output, but main logic is in the dup. – ALollz Apr 15 '19 at 17:52

0 Answers0