24

I'm doing a complex calculation on a data frame that is bound to throw exceptions if all the values in a column are zeros. How to do a quick check whether a column is full of zero? i.e. return True if the column has values other than 0 else False.

Aakash Parsi
  • 93
  • 2
  • 10
DevEx
  • 4,337
  • 13
  • 46
  • 68

1 Answers1

46

you can do something like this:

(df['col'] == 0).all()

This will return True if all values are 0 otherwise it will return false

EMKAY
  • 355
  • 5
  • 14
PraveenB
  • 1,270
  • 10
  • 11