@@ -4195,15 +4195,64 @@ def putmask(self, mask, value):
41954195 # coerces to object
41964196 return self .astype (object ).putmask (mask , value )
41974197
4198- def equals (self , other ) -> bool :
4198+ def equals (self , other : Any ) -> bool :
41994199 """
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.
42014211
42024212 Returns
42034213 -------
42044214 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
42074256 """
42084257 if self .is_ (other ):
42094258 return True
0 commit comments