fred.schwartz
fred.schwartz

Reputation: 2155

Delete Pandas dataframe row, where the sum of all columns equals to 0

Is there a way I can drop all rows in a pandas dataframe, where the sum of all columns is equal to 0?

Upvotes: 1

Views: 50

Answers (1)

jezrael
jezrael

Reputation: 863301

You can change logic - select all column with sum not equal 0 with boolean indexing:

df = df[df.sum(axis=1).ne(0)]

Upvotes: 3

Related Questions