File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed
Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -1456,6 +1456,20 @@ def equals(self, other: object) -> bool:
14561456 0 10.0 20.0
14571457 >>> df.equals(different_data_type)
14581458 False
1459+
1460+ DataFrames with NaN in the same locations compare equal.
1461+
1462+ >>> import numpy as np
1463+ >>> df_nan1 = pd.DataFrame({"a": [1, np.nan], "b": [3, np.nan]})
1464+ >>> df_nan2 = pd.DataFrame({"a": [1, np.nan], "b": [3, np.nan]})
1465+ >>> df_nan1.equals(df_nan2)
1466+ True
1467+
1468+ If the NaN values are not in the same locations, they compare unequal.
1469+
1470+ >>> df_nan3 = pd.DataFrame({"a": [1, np.nan], "b": [3, 4]})
1471+ >>> df_nan1.equals(df_nan3)
1472+ False
14591473 """
14601474 if not (isinstance (other , type (self )) or isinstance (self , type (other ))):
14611475 return False
You can’t perform that action at this time.
0 commit comments