w3resource

Pandas Series: duplicated() function

Indicate duplicate Series values

The duplicated() function is used to 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.

Syntax:

Series.duplicated(self, keep='first')
Pandas Series duplicated image

Parameters:

Name Description Type/Default Value Required / Optional
keep
  • ‘first’ : Mark duplicates as True except for the first occurrence.
  • ‘last’ : Mark duplicates as True except for the last occurrence.
  • False : Mark all duplicates as True.
{‘first’, ‘last’, False},
Default Value: ‘first’
Required

Returns: Series indicating whether each value has occurred in the preceding values.

Example:


Download the above Notebook from here.



Inviting useful, relevant, well-written and unique guest posts