Home > Software design >  Why is pandas compare not working when comparing two dataframes?
Why is pandas compare not working when comparing two dataframes?

Time:11-10

I am creating two dataframes, that I set equal to eachother based on an index field. So each frame has the same indices on both sides and I sort them as well. I want to return the differences between these fields, so as to catch any of the rows that have 'updated' since the last run. But I am getting a weird result.

  df1.compare(df2)

enter image description here

I fail to see any differences here, and when I manually look at the id's involved I do not see any changes at all. What could be causing this?

CodePudding user response:

If you look at the below code: enter image description here

It's working.

Can you please share both of your dfs so that we can assist you better.

CodePudding user response:

I solved it and will post this in case someone else gets stuck. Apparently Nulls were being interpreted as 'None' when read into the dataframe. But the other dataframe actually had the String 'None' vs null. You would never know this by pulling these into dataframes, as they would look identical to the eye.

It took me a while to realize this and hopefully this saves someone else some time.

  • Related