Could you guys please help me explain the code below:
Why a nan
is not np.nan
?
import pandas as pd
import numpy as np
df.iloc[31464]['SalesPersonID']
[out]:
nan
df.iloc[31464]['SalesPersonID'] is np.nan
[out]:
False
Thank you, all.
np.nan
is a special value in numpy. Read here for more information on it.
The link above mentions the following code snippet:
>>> np.nan == np.nan # is always False! Use special numpy functions instead.
Also, type(df.iloc[31464]['SalesPersonID'])
is np.float64
.
use np.isnan(np.nan)
which gives True or
np.isnan(df.iloc[31464]['SalesPersonID'])
which gives True
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With