counting the number of non-nan elements in a numpy ndarray matrix in python,np.count_nonzero(~np.isnan(data))