-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
  • 11,491
  • 24
  • 77
  • 114

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,575
  • 4
  • 16
  • 38