How to remove multiple rows of the same person id in csv file

Viewed 33
df = pd.read_csv('time_var.txt', header = None, delimiter =r"\s+" )
df.columns = ["Id", "Edu", "Ln(w)", "PoEp","Ttd"]

I have a csv file like this:

enter image description here

This is the data set. Each person has multiple entries. I want to take only the first entry for each person.

1 Answers

Try:

df.drop_duplicates(subset='Id', keep='first')
Related