-3

There has a dataframe, one column, e.g., 'cost', have some zero/empty entries, I would like to keep the rows whose 'cost' column are not zero/empty. How to do it in Pandas?

user288609
  • 12,465
  • 26
  • 85
  • 127

1 Answers1

1

You have to perform two filters, first drop the nan values:

df.dropna(subset = ['cost'],inplace = True)

And then drop the zeros values as well:

df = df.loc[df.cost != 0]
ysearka
  • 3,805
  • 5
  • 20
  • 41