numpy.isnan(a)
Test element-wise for NaN and return result as a boolean array.
输出:
True where x is NaN, false otherwise. This is a scalar if x is a scalar.
返回一个和a的shape相同的数组,如果原数组中的元素为nan,则输出数组对应位置上为True,反之为False
示例
import numpy as np
a = np.array([[1, 2], [3, np.nan]])
print(np.isnan(a))
结果
[[False False]
[False True]]