Skip to content

Commit b16621c

Browse files
csfarkasjorisvandenbossche
authored andcommitted
DOC: update the Index.get duplicates docstring (#20322)
1 parent ed77b5b commit b16621c

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

pandas/core/indexes/base.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -1810,6 +1810,10 @@ def get_duplicates(self):
18101810
[2.0, 3.0]
18111811
>>> pd.Index(['a', 'b', 'b', 'c', 'c', 'c', 'd']).get_duplicates()
18121812
['b', 'c']
1813+
1814+
Note that for a DatetimeIndex, it does not return a list but a new
1815+
DatetimeIndex:
1816+
18131817
>>> dates = pd.to_datetime(['2018-01-01', '2018-01-02', '2018-01-03',
18141818
... '2018-01-03', '2018-01-04', '2018-01-04'],
18151819
... format='%Y-%m-%d')
@@ -1830,11 +1834,6 @@ def get_duplicates(self):
18301834
... format='%Y-%m-%d')
18311835
>>> pd.Index(dates).get_duplicates()
18321836
DatetimeIndex([], dtype='datetime64[ns]', freq=None)
1833-
1834-
Notes
1835-
-----
1836-
In case of datetime-like indexes, the function is overridden where the
1837-
result is converted to DatetimeIndex.
18381837
"""
18391838
from collections import defaultdict
18401839
counter = defaultdict(lambda: 0)

0 commit comments

Comments
 (0)