Find missing data
Write a NumPy program to find the missing (NaN) values in an array.
[[1, 5, nan], [8, nan, 9]]
[[False False True] [False True False]] 2 missing
Approach
np.isnan().
Solution
import numpy as npa = np.array([[1, 5, np.nan], [8, np.nan, 9]])print(np.isnan(a))print(np.isnan(a).sum(), "missing")[[False False True] [False True False]] 2 missing
Learn the concept
New to this topic? Read the lesson, then come back.