Skip to content

DOC: Improve df.equals() docstring #56458

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1451,8 +1451,8 @@ def equals(self, other: object) -> bool_t:
the same location are considered equal.

The row/column index do not need to have the same type, as long
as the values are considered equal. Corresponding columns must be of
the same dtype.
as the values are considered equal. Corresponding columns and
index must be of the same dtype.
Comment on lines -1454 to +1455
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure this is a good clarification? Because now this second sentence is contradicting with the first sentence ("row/column index do not need to have the same dtype") ..

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It also doesn't seem to be true that the index dtype has to be the same (as also shown in the examples section):

In [12]: s1 = pd.Series([1, 2, 3])

In [13]: s2 = pd.Series([1, 2, 3], index=pd.Index([0., 1., 2.]))

In [14]: s1.equals(s2)
Out[14]: True

In [15]: s1.index.dtype
Out[15]: dtype('int64')

In [16]: s2.index.dtype
Out[16]: dtype('float64')


Parameters
----------
Expand Down