Location of the documentation
https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.equals.html
Documentation problem
DataFrame.equals(self, other)
Test whether two objects contain the same elements.
This function allows two Series or DataFrames to be compared against each other to see if they have
the same shape and elements. NaNs in the same location are considered equal.
The column headers do not need to have the same type, but the elements within the columns
must be the same dtype.
Suggested fix for documentation
But in fact, (row) indices are also compared:
df = pd.DataFrame([ [1] ], columns=['a'], index=[0])
not_exactly_equal = pd.DataFrame([ [1] ], columns=['a'], index=[1])
df.equals(not_exactly_equal) # => False
P.S. And what is column header type
?
One more: does the elements within the columns must be the same dtype
mean columns should have the same dtype
? Or: type(df1.iloc[i, j]) == type(df2.iloc[i, j])
?
Comment From: TomAugspurger
I believe that's saying a.equals(b)
is True when the columns have perhaps different dtypes but the same values.
In [87]: df = pd.DataFrame([[1]])
In [88]: df2 = df.copy()
In [89]: df2.columns = df2.columns.astype(object)
In [90]: df.equals(df2)
Out[90]: True
A PR clarifying this would be welcome, but we don't need an issue open for it I think.
Comment From: kuraga
@TomAugspurger , I'm not sure if I can clarify right. But it's still actual.