Pandas Dataframe Comparison and Floating Point Precision

后端 未结 1 701
萌比男神i
萌比男神i 2020-12-06 17:25

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

相关标签:
1条回答
  • 2020-12-06 17:52

    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

    0 讨论(0)
提交回复
热议问题