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

前端 未结 4 1127
粉色の甜心
粉色の甜心 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 18:45

    Although it is late, someone else might find it helpful. I had similar issue. But the following worked best for me.

    df =pd.read_csv(r'your file')
    df =df[df['your column name'] !=0]
    

    reference: Drop rows with all zeros in pandas data frame see @ikbel benabdessamad

提交回复
热议问题