Reputation: 2365
My data frame-
df = pd.DataFrame([[1,2,0],[4,5,0],[7,8,0]])
I want to calculate the number of columns which have all the rows as zero in it. In the above case, the 3rd column has all zeros so the output would be 1
Upvotes: 2
Views: 485
Reputation: 1102
this would easy and compact solution try it
df = pd.DataFrame([[0,2,0],[0,5,0],[0,8,0]])
df=(df.sum())
answer=(df==0).sum()
Upvotes: 0