'Pandas data precision [another]

I got an unexpected behaviour, at least for me, while working with pandas dataframe. I use a 2d array to check if the values are smaller than. If I check the entire Dataframe at once, the check is wrong at some values. But if I check explicitly the concerned cell the result is correct.

print(df.loc[5,397])
out: 14.4  #--> its actually 14.3999996185

print(df.loc[5,397] < 14.4)
out: True

print(df.loc[4:6,396:398] < 14.4)
out:
     396    397    398
4  False  False  False
5  False  False  False   #[5,397] should be True!
6  False  False  False

However, if I try to reproduce the error, I got the correct result?!

data = numpy.array([[15,15,15], [15,14.3999996185,15], [15,15,15]])
df = pd.DataFrame(data)

print(df.loc[1,1])
out: 14.3999996185
print(df.loc[1,1] < 14.4)
out: True
print(df < 14.4)
out:
       0      1      2
0  False  False  False
1  False   True  False
2  False  False  False

Thank you



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source