📜  有效地计算numpy数组中的零元素? - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:23.456000             🧑  作者: Mango

代码示例1
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