Series.duplicated(self, keep='first')
[source]
Indicate duplicate Series values.
Duplicated values are indicated as True
values in the resulting Series. Either all duplicates, all except the first or all except the last occurrence of duplicates can be indicated.
Parameters: |
|
---|---|
Returns: |
|
See also
Index.duplicated
DataFrame.duplicated
Series.drop_duplicates
By default, for each set of duplicated values, the first occurrence is set on False and all others on True:
>>> animals = pd.Series(['lama', 'cow', 'lama', 'beetle', 'lama']) >>> animals.duplicated() 0 False 1 False 2 True 3 False 4 True dtype: bool
which is equivalent to
>>> animals.duplicated(keep='first') 0 False 1 False 2 True 3 False 4 True dtype: bool
By using ‘last’, the last occurrence of each set of duplicated values is set on False and all others on True:
>>> animals.duplicated(keep='last') 0 True 1 False 2 True 3 False 4 False dtype: bool
By setting keep on False
, all duplicates are True:
>>> animals.duplicated(keep=False) 0 True 1 False 2 True 3 False 4 True dtype: bool
© 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.Series.duplicated.html