Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check if dataframe has a zero element

In a pandas dataframe, what is the quickest way to check if at least one element is 0? Imagine the data is :

Name   Asset  Revenue
A       10     20
B       0      21

I need to return true because at least one element is 0. One element across the dataframe, not one element per row/column

like image 237
Victor Avatar asked Jun 08 '18 19:06

Victor


1 Answers

Maybe using any twice

df.eq(0).any().any()
Out[173]: True
like image 89
BENY Avatar answered Oct 02 '22 22:10

BENY