5

i have a dataframe data and csv data as following enter image description here

enter image description here

i want to append the dataframe data to the csv file.however ,there are duplicates between the two data.so how to remove the duplicates and append new data to csv file.

1 Answer 1

6

I think you need read_csv with DataFrame.append, then drop_duplicates and last to_csv:

pd.read_csv('file').append(df).drop_duplicates().to_csv('file')
Sign up to request clarification or add additional context in comments.

1 Comment

to_csv instead of to_file :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.