Drop row in pandas dataframe if any value in the row equals zero

前端 未结 4 1125
粉色の甜心
粉色の甜心 2020-12-05 18:07

How do I drop a row if any of the values in the row equal zero?

I would normally use df.dropna() for NaN values but not sure how to do it with \"0\" values.

4条回答
  •  暖寄归人
    2020-12-05 19:01

    i think the easiest way is looking at rows where all values are not equal to 0:

    df[(df != 0).all(1)]
    

提交回复
热议问题