@@ -4325,8 +4325,60 @@ def drop_duplicates(self, keep='first'):
43254325 """
43264326 return super (Index , self ).drop_duplicates (keep = keep )
43274327
4328- @Appender (base ._shared_docs ['duplicated' ] % _index_doc_kwargs )
43294328 def duplicated (self , keep = 'first' ):
4329+ """
4330+ Indicate duplicate index values.
4331+
4332+ Duplicated values are indicated as ``True`` values in the resulting
4333+ array. Either all duplicates, all except the first, or all except the
4334+ last occurrence of duplicates can be indicated.
4335+
4336+ Parameters
4337+ ----------
4338+ keep : {'first', 'last', False}, default 'first'
4339+ The value or values in a set of duplicates to mark as missing.
4340+
4341+ - 'first' : Mark duplicates as ``True`` except for the first
4342+ occurrence.
4343+ - 'last' : Mark duplicates as ``True`` except for the last
4344+ occurrence.
4345+ - ``False`` : Mark all duplicates as ``True``.
4346+
4347+ Examples
4348+ --------
4349+ By default, for each set of duplicated values, the first occurrence is
4350+ set to False and all others to True:
4351+
4352+ >>> idx = pd.Index(['lama', 'cow', 'lama', 'beetle', 'lama'])
4353+ >>> idx.duplicated()
4354+ array([False, False, True, False, True])
4355+
4356+ which is equivalent to
4357+
4358+ >>> idx.duplicated(keep='first')
4359+ array([False, False, True, False, True])
4360+
4361+ By using 'last', the last occurrence of each set of duplicated values
4362+ is set on False and all others on True:
4363+
4364+ >>> idx.duplicated(keep='last')
4365+ array([ True, False, True, False, False])
4366+
4367+ By setting keep on ``False``, all duplicates are True:
4368+
4369+ >>> idx.duplicated(keep=False)
4370+ array([ True, False, True, False, True])
4371+
4372+ Returns
4373+ -------
4374+ numpy.ndarray
4375+
4376+ See Also
4377+ --------
4378+ pandas.Series.duplicated : Equivalent method on pandas.Series
4379+ pandas.DataFrame.duplicated : Equivalent method on pandas.DataFrame
4380+ pandas.Index.drop_duplicates : Remove duplicate values from Index
4381+ """
43304382 return super (Index , self ).duplicated (keep = keep )
43314383
43324384 _index_shared_docs ['fillna' ] = """
0 commit comments