xxxxxxxxxx
import math
value = math.nan
math.isnan(value) ## Returns True
value = 45.45
math.isnan(value) ## Returns False
xxxxxxxxxx
# check nan value in scratch without libraries
def isnan(val):
return type(val) == float and not float('-inf') <= val <= float('inf' )
value = float('nan')
isnan(value) # return True for nan value
xxxxxxxxxx
import pandas as pd
pd.isnull(df.columnName).sum()
pd.notnull(df.columnName).sum()
xxxxxxxxxx
# 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])