I have a dataset that looks like this, where the third column is derived by dividing the first column by the second:
A_CLOSE_PRICE B_CLOSE_PRICE A_CLOSE_PRICE/B_CLOSE_PRICE
0 113.55 0.00 inf
1 97.85 80.00 1.223125
2 60.00 70.00 0.857143
3 51.65 51.65 1.000000
4 53.50 NaN NaN
5 NaN 1649.60 NaN
6 40.00 40.50 0.987654
7 1.10 1.00 1.100000
As I want to display the rows containing more than a 10% difference, I run this:
(df['A_CLOSE_PRICE/B_CLOSE_PRICE'] - 1 ).abs() > 0.1
But the last row as shown below returns me "True" instead of "False", which looks to me like a floating point issue. Does anyone know what should be the proper handling for this so I can get the correct results?
0 True
1 True
2 True
3 False
4 False
5 False
6 False
7 True