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 pandas as pd
import numpy as np
df = pd.DataFrame(
[[np.nan, 72, 67],
[23, 78, 62],
[32, 74, np.nan],
[np.nan, 54, 76]],
columns=['a', 'b', 'c'])
value = df.at[0, 'a'] #nan
isNaN = np.isnan(value)
print("Is value at df[0, 'a'] NaN :", isNaN)
value = df.at[0, 'b'] #72
isNaN = np.isnan(value)
print("Is value at df[0, 'b'] NaN :", isNaN)