import numpy as np mynan = np.nan mynum = 18 print("NaN? : ", np.isnan(mynan)) # Use np.isnan() to test print("NaN? : ", np.isnan(mynum)) # Results: # Nan? : True # NaN? : False