Home > Net >  fail to see what the difference is between 2 dataframes
fail to see what the difference is between 2 dataframes

Time:10-28

I have 2 dataframes which should be the same

df1 is retrieved from a database, then:

df1.to_csv('raw data.csv')
df2 = pd.read_csv('raw data.csv', index_col=0, parse_dates=True)

(Even I don't use the parse_dates parameter my problem stays the same) df1 and df2 have the same shape and also looks the same

But when I tried

df1.equals(df2)

I get False

Then with df1.compare(df2)

I get

Empty DataFrame
Columns: []
Index: []

what could be the reason the equals method returns False?

CodePudding user response:

You might get clues by running

pd.testing.assert_frame_equal(df1, df2)

and see what the error message says

https://pandas.pydata.org/docs/reference/api/pandas.testing.assert_frame_equal.html

  • Related