drop_duplicates not working in pandas?

前端 未结 5 685
抹茶落季
抹茶落季 2020-12-07 01:58

The purpose of my code is to import 2 Excel files, compare them, and print out the differences to a new Excel file.

However, after concatenating all the data, and us

5条回答
  •  渐次进展
    2020-12-07 02:46

    Might help anyone in the future.

    I had a column with dates, where I tried to remove duplicates without success. If it's not important to keep the column as a date for further operations, I converted the column from type object to string.

    df = df.astype('str')
    

    Then I performed @Keith answers

    df = df.drop_duplicates(subset=None, keep="first", inplace=True)
    

提交回复
热议问题