I thought this solution would solve my problem but the op here needed to check if the rows of his two data frames contained a difference. I want to do the same but for the columns. The solution was ne = (df1 != df2).any(1)
but that does not help with my columns. Yes, I just checked and both of my dataframes have exactly the same shape
. If I do df1 == df2
it gives me a new data frame full of trues and falses. Looking at the first hundred rows it looks like most of the columns with a few exceptions are equal. How can you just get one True / False for each column?
Here is a toy example:
import numpy as np
import pandas as pd
df1 = pd.DataFrame(np.random.randint(low=0, high=10, size=(5, 5)), columns=['a', 'b', 'c', 'd', 'e'])
df2 = df1.copy()
df2.at[3,'d'] += 10
Desired output:
A True
B True
C True
D False
E True