drop_duplicates not working in pandas?

前端 未结 5 671
抹茶落季
抹茶落季 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条回答
  •  -上瘾入骨i
    2020-12-07 02:48

    If you have are using a DatetimeIndex in your DataFrame this will not work

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

    Instead one can use:

    df = df[~df.index.duplicated()]
    

提交回复
热议问题