14

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.

SKY AP
  • 75
  • 2
  • 9
DevEx
  • 3,702
  • 12
  • 43
  • 60

1 Answers1

31

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
  • 369
  • 5
  • 14
PraveenB
  • 1,042
  • 8
  • 11