Skip to content

DEPR: Index.get_duplicates #20239

Closed
@jreback

Description

@jreback

completely duplicates (pun-intended) .duplicated / .drop_duplicates and is unecessary.

In [1]: pd.Index([1, 2, 3, 2, 3, 4, 3]).get_duplicates()
Out[1]: [2, 3]

In [2]: pd.Index([1, 2, 3, 2, 3, 4, 3]).drop_duplicates()
Out[2]: Int64Index([1, 2, 3, 4], dtype='int64')

In [3]: pd.Index([1, 2, 3, 2, 3, 4, 3]).duplicated()
Out[3]: array([False, False, False,  True,  True, False,  True])

In [4]: i = pd.Index([1, 2, 3, 2, 3, 4, 3])

In [5]: i[i.duplicated()]
Out[5]: Int64Index([2, 3, 3], dtype='int64')

In [6]: i[i.duplicated()].unique()
Out[6]: Int64Index([2, 3], dtype='int64')

Metadata

Metadata

Assignees

No one assigned

    Labels

    DeprecateFunctionality to remove in pandasIndexingRelated to indexing on series/frames, not to indexes themselves

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions