efficiently count zero elements in numpy array 3f

Solutions on MaxInterview for efficiently count zero elements in numpy array 3f by the best coders in the world

we are a community of more than 2 million smartest coders
registration for
employee referral programs
are now open
get referred to google, amazon, flipkart and more
register now
  
pinned-register now
showing results for - "efficiently count zero elements in numpy array 3f"
Assya
23 Oct 2020
1In [3]: arr
2Out[3]: 
3array([[1, 2, 0, 3],
4      [3, 9, 0, 4]])
5
6In [4]: np.count_nonzero(arr==0)
7Out[4]: 2
8
9In [5]:def func_cnt():
10            for arr in arrs:
11                zero_els = np.count_nonzero(arr==0)
12                # here, it counts the frequency of zeroes actually