How to analyze all duplicate entries in this Pandas DataFrame?

后端 未结 3 1971
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-05 03:13

I\'d like to be able to compute descriptive statistics on data in a Pandas DataFrame, but I only care about duplicated entries. For example, let\'s say I have the DataFrame

3条回答
  •  被撕碎了的回忆
    2020-12-05 03:59

    To get a list of all the duplicated entries with Pandas version 0.17, you can simply set 'keep = False' in the duplicated function.

    frame[frame.duplicated(['key1','key2'],keep=False)]
    
        key1  key2  data
    0     1     2     5
    1     2     2     6
    3     1     2     6
    4     2     2     1
    6     2     2     2
    7     2     2     8
    

提交回复
热议问题