How to find duplicate names using pandas?

前端 未结 6 1271
無奈伤痛
無奈伤痛 2020-12-14 02:27

I have a pandas.DataFrame with a column called name containing strings. I would like to get a list of the names which occur more than once in the c

6条回答
  •  無奈伤痛
    2020-12-14 03:04

    value_counts will give you the number of duplicates as well.

    names = df.name.value_counts()
    names[names > 1]
    

提交回复
热议问题