(np.where(np.isnan(A)))[0].shape[0]
will be greater than 0
if A
contains at least one element of nan
, A
could be an n x m
matrix.
Example:
import numpy as np
A = np.array([1,2,4,np.nan])
if (np.where(np.isnan(A)))[0].shape[0]:
print "A contains nan"
else:
print "A does not contain nan"