Index.duplicated(self, keep='first')
[source]
Indicate duplicate index values.
Duplicated values are indicated as True
values in the resulting array. Either all duplicates, all except the first, or all except the last occurrence of duplicates can be indicated.
Parameters: |
|
---|---|
Returns: |
|
See also
Series.duplicated
DataFrame.duplicated
Index.drop_duplicates
By default, for each set of duplicated values, the first occurrence is set to False and all others to True:
>>> idx = pd.Index(['lama', 'cow', 'lama', 'beetle', 'lama']) >>> idx.duplicated() array([False, False, True, False, True])
which is equivalent to
>>> idx.duplicated(keep='first') array([False, False, True, False, True])
By using ‘last’, the last occurrence of each set of duplicated values is set on False and all others on True:
>>> idx.duplicated(keep='last') array([ True, False, True, False, False])
By setting keep on False
, all duplicates are True:
>>> idx.duplicated(keep=False) array([ True, False, True, False, True])
© 2008–2012, AQR Capital Management, LLC, Lambda Foundry, Inc. and PyData Development Team
Licensed under the 3-clause BSD License.
https://pandas.pydata.org/pandas-docs/version/0.25.0/reference/api/pandas.Index.duplicated.html