From 17eac116e147634a891b635bddf850c5394f4304 Mon Sep 17 00:00:00 2001 From: Greg Gandenberger Date: Fri, 12 Jan 2018 13:35:36 -0600 Subject: [PATCH 1/2] Clarify equals method docstring Make explicit that equals method requires that columns have the same dtypes but not that indices have the same types (e.g. `pd.DataFrame({1:[0], 0:[1]}).equals(pd.DataFrame({1.0:[0], 0.0:[1]}))` returns `True` while `pd.DataFrame({1:[0], 0:[1]}, dtype='float32').equals(pd.DataFrame({1:[0], 0:[1]}, dtype='float64'))` returns `False`) --- pandas/core/generic.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index cef1e551f948e..1d98478ee0251 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -1047,7 +1047,8 @@ def __invert__(self): def equals(self, other): """ - Determines if two NDFrame objects contain the same elements. NaNs in + Determines if two NDFrame objects have equal indices, equal + elements, and the same dtypes at corresponding locations. NaNs in the same location are considered equal. """ if not isinstance(other, self._constructor): From 3bc9bfd76c10c57eab137458d12ffc48ab90317c Mon Sep 17 00:00:00 2001 From: Greg Gandenberger Date: Sat, 13 Jan 2018 14:05:23 -0600 Subject: [PATCH 2/2] Change "indices" to "column labels." --- pandas/core/generic.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 1d98478ee0251..6d1cbdc3785cd 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -1047,9 +1047,9 @@ def __invert__(self): def equals(self, other): """ - Determines if two NDFrame objects have equal indices, equal - elements, and the same dtypes at corresponding locations. NaNs in - the same location are considered equal. + Determines if two NDFrame objects have equal columns labels, equal + elements, and the same dtypes at corresponding locations. NaNs in the + same location are considered equal. """ if not isinstance(other, self._constructor): return False