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?
Asked
Active
Viewed 367 times
1 Answers
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