Dropping duplicates in Pandas excluding one column

后端 未结 1 329
野性不改
野性不改 2020-12-28 15:25

This seems simple, but I can not find any information on it on the internet

I have a dataframe like below

City    State Zip           Date        Des         


        
相关标签:
1条回答
  • 2020-12-28 16:21

    You've actually found the solution. For multiple columns, subset will be a list.

    df.drop_duplicates(subset=['City', 'State', 'Zip', 'Date']) 
    

    Or, just by stating the column to be ignored:

    df.drop_duplicates(subset=df.columns.difference(['Description']))
    
    0 讨论(0)
提交回复
热议问题