Python | Pandas Series.drop_duplicates()
Last Updated :
13 Feb, 2019
Improve
Pandas
Python3
Output :
Now we will use
Python3 1==
Output :
As we can see in the output, the
Python3
Output :
Now we will use
Python3 1==
Output :
As we can see in the output, the
Series.drop_duplicates()
function returns a series object with duplicate values removed from the given series object.
Syntax: Series.drop_duplicates(keep='first', inplace=False) Parameter : keep : {‘first’, ‘last’, False}, default ‘first’ inplace : If True, performs operation inplace and returns None. Returns : deduplicated : SeriesExample #1: Use
Series.drop_duplicates()
function to drop the duplicate values from the given series object.
# importing pandas as pd
import pandas as pd
# Creating the Series
sr = pd.Series([80, 25, 3, 25, 24, 6])
# Create the Index
index_ = ['Coca Cola', 'Sprite', 'Coke', 'Fanta', 'Dew', 'ThumbsUp']
# set the index
sr.index = index_
# Print the series
print(sr)

Series.drop_duplicates()
function to drop the duplicate values in the underlying data of the given series object.
# drop duplicates
result = sr.drop_duplicates()
# Print the result
print(result)

Series.drop_duplicates()
function has successfully dropped the duplicate entries from the given series object.
Example #2 : Use Series.drop_duplicates()
function to drop the duplicate values from the given series object.
# importing pandas as pd
import pandas as pd
# Creating the Series
sr = pd.Series([11, 11, 8, 18, 65, 18, 32, 10, 5, 32, 32])
# Create the Index
index_ = pd.date_range('2010-10-09', periods = 11, freq ='M')
# set the index
sr.index = index_
# Print the series
print(sr)

Series.drop_duplicates()
function to drop the duplicate values in the underlying data of the given series object.
# drop duplicates
result = sr.drop_duplicates()
# Print the result
print(result)

Series.drop_duplicates()
function has successfully dropped the duplicate entries from the given series object.