Because of the error, I cannot drop the duplicates using following code:
cc.drop_duplicates(subset="StateAbb")
How can I sole the issue?
CodePudding user response:
StateAbb is the index , you can't de-duplicate index . you can do this :
cc = cc.reset_index().drop_duplicates(subset="StateAbb").set_index('StateAbb')
CodePudding user response:
Use boolean indexing with Index.duplicated
and boolean NOT (~
):
cc = cc[~cc.index.duplicated()]