How to remove duplicate values of a variable using python?

Description

To remove duplicate values in a variable
by using python.

  Read the sample data.

  Import necessary packages.

  Create data frame.

  Remove the duplicate by using
 df.drop_duplicates().

#import library functions

import pandas as pd

#Read the data set

data=pd.read_csv(‘/home/soft27/soft27

/Sathish/Pythonfiles/Employee.csv’)

#create data frame

df=pd.DataFrame(data)

print(“Original data frame\n”)

print(df)

#Remove duplicate

rem_dup=df.drop_duplicates([‘name’])

print(“After removing duplicate\n”)

print(rem_dup)

Leave Comment

Your email address will not be published. Required fields are marked *

clear formSubmit