1import numpy as np
2
3mynan = np.nan
4mynum = 18
5
6print("NaN? : ", np.isnan(mynan)) # Use np.isnan() to test
7print("NaN? : ", np.isnan(mynum))
8
9# Results:
10# Nan? : True
11# NaN? : False
1import math
2print math.isnan(float('NaN'))OutputTrue
3print math.isnan(1.0)OutputFalse
4
1import numpy as np
2import pandas as pd
3
4val = np.nan
5
6print(pd.isnull(val))
7# True