Pandas drop_duplicates method not working

前端 未结 3 1204
梦谈多话
梦谈多话 2020-12-29 22:34

I am trying to use drop_duplicates method on my dataframe, but I am getting an error. See the following:

error: TypeError: unhashable type: \'list\'<

3条回答
  •  有刺的猬
    2020-12-29 23:26

    Overview: you can see which rows are duplicated

    Method 1:

    df2=df.copy()
    mylist=df2.iloc[0,1]
    df2.iloc[0,1]=' '.join(map(str,mylist))
    
    mylist=df2.iloc[1,1]
    df2.iloc[1,1]=' '.join(map(str,mylist))
    
    duplicates=df2.duplicated(keep=False)
    print(df2[duplicates])
    

    Method 2:

    print(df.astype(str).duplicated(keep=False))
    

提交回复
热议问题