count number of zeros in a number python
# credit to Stack Overflow user in source link
>>> def count_zeros(number):
... return str(number).count('0')
...
>>> count_zeros(49690101904335902069)
5
count number of zeros in a number python
# credit to Stack Overflow user in source link
>>> def count_zeros(number):
... return str(number).count('0')
...
>>> count_zeros(49690101904335902069)
5
Efficiently count zero elements in numpy array?
In [3]: arr
Out[3]:
array([[1, 2, 0, 3],
[3, 9, 0, 4]])
In [4]: np.count_nonzero(arr==0)
Out[4]: 2
In [5]:def func_cnt():
for arr in arrs:
zero_els = np.count_nonzero(arr==0)
# here, it counts the frequency of zeroes actually
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us