@@ -1303,8 +1303,85 @@ def __invert__(self):
13031303
13041304 def equals (self , other ):
13051305 """
1306- Determines if two NDFrame objects contain the same elements. NaNs in
1307- the same location are considered equal.
1306+ Test whether two objects contain the same elements.
1307+
1308+ This function allows two Series or DataFrames to be compared against
1309+ each other to see if they have the same shape and elements. NaNs in
1310+ the same location are considered equal. The column headers do not
1311+ need to have the same type, but the elements within the columns must
1312+ be the same dtype.
1313+
1314+ Parameters
1315+ ----------
1316+ other : Series or DataFrame
1317+ The other Series or DataFrame to be compared with the first.
1318+
1319+ Returns
1320+ -------
1321+ bool
1322+ True if all elements are the same in both objects, False
1323+ otherwise.
1324+
1325+ See Also
1326+ --------
1327+ Series.eq : Compare two Series objects of the same length
1328+ and return a Series where each element is True if the element
1329+ in each Series is equal, False otherwise.
1330+ DataFrame.eq : Compare two DataFrame objects of the same shape and
1331+ return a DataFrame where each element is True if the respective
1332+ element in each DataFrame is equal, False otherwise.
1333+ assert_series_equal : Return True if left and right Series are equal,
1334+ False otherwise.
1335+ assert_frame_equal : Return True if left and right DataFrames are
1336+ equal, False otherwise.
1337+ numpy.array_equal : Return True if two arrays have the same shape
1338+ and elements, False otherwise.
1339+
1340+ Notes
1341+ -----
1342+ This function requires that the elements have the same dtype as their
1343+ respective elements in the other Series or DataFrame. However, the
1344+ column labels do not need to have the same type, as long as they are
1345+ still considered equal.
1346+
1347+ Examples
1348+ --------
1349+ >>> df = pd.DataFrame({1: [10], 2: [20]})
1350+ >>> df
1351+ 1 2
1352+ 0 10 20
1353+
1354+ DataFrames df and exactly_equal have the same types and values for
1355+ their elements and column labels, which will return True.
1356+
1357+ >>> exactly_equal = pd.DataFrame({1: [10], 2: [20]})
1358+ >>> exactly_equal
1359+ 1 2
1360+ 0 10 20
1361+ >>> df.equals(exactly_equal)
1362+ True
1363+
1364+ DataFrames df and different_column_type have the same element
1365+ types and values, but have different types for the column labels,
1366+ which will still return True.
1367+
1368+ >>> different_column_type = pd.DataFrame({1.0: [10], 2.0: [20]})
1369+ >>> different_column_type
1370+ 1.0 2.0
1371+ 0 10 20
1372+ >>> df.equals(different_column_type)
1373+ True
1374+
1375+ DataFrames df and different_data_type have different types for the
1376+ same values for their elements, and will return False even though
1377+ their column labels are the same values and types.
1378+
1379+ >>> different_data_type = pd.DataFrame({1: [10.0], 2: [20.0]})
1380+ >>> different_data_type
1381+ 1 2
1382+ 0 10.0 20.0
1383+ >>> df.equals(different_data_type)
1384+ False
13081385 """
13091386 if not isinstance (other , self ._constructor ):
13101387 return False
0 commit comments