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
import math
x = float('nan')
math.isnan(x)
True
math.isnan(n)
Number.isNaN(123)
>>> pd.isnull(None)
True
import math
print math.isnan(float('NaN'))OutputTrue
print math.isnan(1.0)OutputFalse
# If you are doing any conditional operation and you want to check a if
# a single value is Null or not then you can use numpy's isna method.
np.isna(df[col][0])