I'd recommend to find what's the difference first, but it is hard with the pd.equals
since it will only give you either True
or False
, can you try this?
from pandas._testing import assert_frame_equal
assert_frame_equal(df1, df2)
This will tell you exactly the difference, and it has different levels of 'tolerance' (for example if you don't care about the column names, of the types etc)
Details here
If you want to compare with a tolerance in values:
In [20]: from pandas._testing import assert_frame_equal
...: df1 = pd.DataFrame({'a': [1, 2], 'b': [3, 4], 'c': [1, 9]})
...: df2 = pd.DataFrame({'a': [1, 2], 'b': [3, 5], 'c': [1.5, 8.5]})
In [21]: assert_frame_equal(df1, df2, check_less_precise=-1, check_dtype=False)
By defaut chekc_dtype
is True, so it will raise an exception if you have floats vs ints.
The other parameter to change is the check_less_precise
by using negatives you make the allowed error bigger