check variable is nan python code example Example 1: python test is nan math.isnan(n) Example 2: check is string is nan python >>> pd.isnull(None) True