[Numpy-discussion] counting non-zero entries in an ndarray
Thomas K Gamble
Wed Dec 22 11:43:55 CST 2010
On Wednesday, December 22, 2010 07:16:17 am Ian Stokes-Rees wrote:
> What is the most efficient way to do the Matlab equivalent of nnz(M)
> (nnz = number-of-non-zeros function)?
> I've tried Google, but no luck.
> My assumption is that something like
> a != 0
> will be used, but I'm not sure then how to "count" the number of "True"
len(where(a != 0))
Thomas K. Gamble
Research Technologist, System/Network Administrator
Chemical Diagnostics and Engineering (C-CDE)
Los Alamos National Laboratory
There cannot be a crisis next week. My schedule is already full.
More information about the NumPy-Discussion