Skip to content Skip to sidebar Skip to footer

Pandas Dataframe Comparison And Floating Point Precision

I'm looking to compare two dataframes which should be identical. However due to floating point precision I am being told the values don't match. I have created an example to simula

Solution 1:

OK you can use np.isclose for this:

In [250]:
np.isclose(a,b)

Out[250]:
array([[ True],
       [ True]], dtype=bool)

np.isclose takes relative tolerance and absolute tolerance. These have default values: rtol=1e-05, atol=1e-08 respectively

Post a Comment for "Pandas Dataframe Comparison And Floating Point Precision"