@@ -4195,15 +4195,64 @@ def putmask(self, mask, value):
4195
4195
# coerces to object
4196
4196
return self .astype (object ).putmask (mask , value )
4197
4197
4198
- def equals (self , other ) -> bool :
4198
+ def equals (self , other : Any ) -> bool :
4199
4199
"""
4200
- Determine if two Index objects contain the same elements.
4200
+ Determine if two Index object are equal.
4201
+
4202
+ The things that are being compared are:
4203
+
4204
+ * The elements inside the Index object.
4205
+ * The order of the elements inside the Index object.
4206
+
4207
+ Parameters
4208
+ ----------
4209
+ other : Any
4210
+ The other object to compare against.
4201
4211
4202
4212
Returns
4203
4213
-------
4204
4214
bool
4205
- True if "other" is an Index and it has the same elements as calling
4206
- index; False otherwise.
4215
+ True if "other" is an Index and it has the same elements and order
4216
+ as the calling index; False otherwise.
4217
+
4218
+ Examples
4219
+ --------
4220
+ >>> idx1 = pd.Index([1, 2, 3])
4221
+ >>> idx1
4222
+ Int64Index([1, 2, 3], dtype='int64')
4223
+ >>> idx1.equals(pd.Index([1, 2, 3]))
4224
+ True
4225
+
4226
+ The elements inside are compared
4227
+
4228
+ >>> idx2 = pd.Index(["1", "2", "3"])
4229
+ >>> idx2
4230
+ Index(['1', '2', '3'], dtype='object')
4231
+
4232
+ >>> idx1.equals(idx2)
4233
+ False
4234
+
4235
+ The oreder is compared
4236
+
4237
+ >>> ascending_idx = pd.Index([1, 2, 3])
4238
+ >>> ascending_idx
4239
+ Int64Index([1, 2, 3], dtype='int64')
4240
+ >>> descending_idx = pd.Index([3, 2, 1])
4241
+ >>> descending_idx
4242
+ Int64Index([3, 2, 1], dtype='int64')
4243
+ >>> ascending_idx.equals(descending_idx)
4244
+ False
4245
+
4246
+ The dtype is *not* compared
4247
+
4248
+ >>> int64_idx = pd.Int64Index([1, 2, 3])
4249
+ >>> int64_idx
4250
+ Int64Index([1, 2, 3], dtype='int64')
4251
+ >>> uint64_idx = pd.UInt64Index([1, 2, 3])
4252
+ >>> uint64_idx
4253
+ UInt64Index([1, 2, 3], dtype='uint64')
4254
+ >>> int64_idx.equals(uint64_idx)
4255
+ True
4207
4256
"""
4208
4257
if self .is_ (other ):
4209
4258
return True
0 commit comments