DEPR: Index.get_duplicates (original) (raw)

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')