We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1895c38 commit 11c8fbeCopy full SHA for 11c8fbe
pandas/core/generic.py
@@ -1456,6 +1456,19 @@ def equals(self, other: object) -> bool:
1456
0 10.0 20.0
1457
>>> df.equals(different_data_type)
1458
False
1459
+
1460
+ DataFrames with NaN in the same locations compare equal.
1461
1462
+ >>> df_nan1 = pd.DataFrame({"a": [1, np.nan], "b": [3, np.nan]})
1463
+ >>> df_nan2 = pd.DataFrame({"a": [1, np.nan], "b": [3, np.nan]})
1464
+ >>> df_nan1.equals(df_nan2)
1465
+ True
1466
1467
+ If the NaN values are not in the same locations, they compare unequal.
1468
1469
+ >>> df_nan3 = pd.DataFrame({"a": [1, np.nan], "b": [3, 4]})
1470
+ >>> df_nan1.equals(df_nan3)
1471
+ False
1472
"""
1473
if not (isinstance(other, type(self)) or isinstance(self, type(other))):
1474
return False
0 commit comments