check if value is NaN pd code example Example 1: to detect if a data frame has nan values df.isnull().sum().sum() 5 Example 2: check if value is NaN Number.isNaN(123)