w3resource

Pandas Series: drop_duplicates() function

Remove Pandas series with duplicate values

The drop_duplicates() function is used to get Pandas series with duplicate values removed.

Syntax:

Series.drop_duplicates(self, keep='first', inplace=False)
Pandas Series drop_duplicates image

Parameters:

Name Description Type/Default Value Required / Optional
keep
  • ‘first’ : Drop duplicates except for the first occurrence.
  • ‘last’ : Drop duplicates except for the last occurrence.
  • False : Drop all duplicates.
{‘first’, ‘last’, False}
Default Value: ‘first’
Required
inplace If True, performs operation inplace and returns None. bool
Default Value: False
Required

Returns: Series
Series with duplicates dropped.

Example:


Download the above Notebook from here.



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