NaN value in NumPy or Pandas is some type dangerous for data processing. Like the example below:

import numpy as np import pandas as pd df = pd.DataFrame({"col1": [None, None, None]}) df["col1"] = df["col1"].astype("float") print(df) print(df["col1"] >= 3.14) print(df["col1"] < 3.14)

col1 0 NaN 1 NaN 2 NaN 0 False 1 False 2 False Name: col1, dtype: bool 0 False 1 False 2 False Name: col1, dtype: bool

If we directly convert “None” to the “float” type, it will become the “NaN” value. The “Nan” couldn’t be compared with real float number therefore it is neither “bigger or equal than” a float-point number nor “smaller than” it.

Since only float-point type could allow the “None” value in a column, we should be much careful when processing with float-point number.