numpy.nan
- 表示空值。
nan = NaN = NAN
【例】两个numpy.nan
是不相等的。
import numpy as np
print(np.nan == np.nan) # False
print(np.nan != np.nan) # True
numpy.isnan(x, *args, **kwargs)
Test element-wise for NaN and return result as a boolean array.
【例】
import numpy as np
x = np.array([1, 1, 8, np.nan, 10])
print(x)
# [ 1. 1. 8. nan 10.]
y = np.isnan(x)
print(y)
# [False False False True False]
z = np.count_nonzero(y)
print(z) # 1