Skip to content

Commit a1c5e51

Browse files
committed
Updated internal refs
1 parent ed58eec commit a1c5e51

File tree

6 files changed

+27
-13
lines changed

6 files changed

+27
-13
lines changed

pandas/core/frame.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -3840,8 +3840,9 @@ def set_index(self, keys, drop=True, append=False, inplace=False,
38403840
index = _ensure_index_from_sequences(arrays, names)
38413841

38423842
if verify_integrity and not index.is_unique:
3843-
duplicates = index.get_duplicates()
3844-
raise ValueError('Index has duplicate keys: %s' % duplicates)
3843+
duplicates = index[index.duplicated()].unique()
3844+
raise ValueError('Index has duplicate keys: {duplicates!s}'.format(
3845+
duplicates=duplicates))
38453846

38463847
for c in to_remove:
38473848
del frame[c]

pandas/core/indexes/datetimelike.py

-4
Original file line numberDiff line numberDiff line change
@@ -501,10 +501,6 @@ def take(self, indices, axis=0, allow_fill=True,
501501
freq = self.freq if isinstance(self, ABCPeriodIndex) else None
502502
return self._shallow_copy(taken, freq=freq)
503503

504-
def get_duplicates(self):
505-
values = Index.get_duplicates(self)
506-
return self._simple_new(values)
507-
508504
_can_hold_na = True
509505

510506
_na_value = NaT

pandas/core/reshape/concat.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ def _get_concat_axis(self):
504504
def _maybe_check_integrity(self, concat_index):
505505
if self.verify_integrity:
506506
if not concat_index.is_unique:
507-
overlap = concat_index.get_duplicates()
507+
overlap = concat_index[concat_index.duplicated()].unique()
508508
raise ValueError('Indexes have overlapping values: '
509509
'{overlap!s}'.format(overlap=overlap))
510510

pandas/tests/indexes/datetimes/test_datetime.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import warnings
12

23
import pytest
34

@@ -178,7 +179,10 @@ def test_get_duplicates(self):
178179
idx = DatetimeIndex(['2000-01-01', '2000-01-02', '2000-01-02',
179180
'2000-01-03', '2000-01-03', '2000-01-04'])
180181

181-
result = idx.get_duplicates()
182+
with warnings.catch_warnings(record=True):
183+
# Deprecated - see GH20239
184+
result = idx.get_duplicates()
185+
182186
ex = DatetimeIndex(['2000-01-02', '2000-01-03'])
183187
tm.assert_index_equal(result, ex)
184188

pandas/tests/indexes/test_multi.py

+12-4
Original file line numberDiff line numberDiff line change
@@ -2413,8 +2413,12 @@ def check(nlevels, with_nulls):
24132413
for a in [101, 102]:
24142414
mi = MultiIndex.from_arrays([[101, a], [3.5, np.nan]])
24152415
assert not mi.has_duplicates
2416-
assert mi.get_duplicates().equals(
2417-
MultiIndex.from_arrays([[], []]))
2416+
2417+
with warnings.catch_warnings(record=True):
2418+
# Deprecated - see GH20239
2419+
assert mi.get_duplicates().equals(MultiIndex.from_arrays(
2420+
[[], []]))
2421+
24182422
tm.assert_numpy_array_equal(mi.duplicated(), np.zeros(
24192423
2, dtype='bool'))
24202424

@@ -2426,8 +2430,12 @@ def check(nlevels, with_nulls):
24262430
labels=np.random.permutation(list(lab)).T)
24272431
assert len(mi) == (n + 1) * (m + 1)
24282432
assert not mi.has_duplicates
2429-
assert mi.get_duplicates().equals(
2430-
MultiIndex.from_arrays([[], []]))
2433+
2434+
with warnings.catch_warnings(record=True):
2435+
# Deprecated - see GH20239
2436+
assert mi.get_duplicates().equals(MultiIndex.from_arrays(
2437+
[[], []]))
2438+
24312439
tm.assert_numpy_array_equal(mi.duplicated(), np.zeros(
24322440
len(mi), dtype='bool'))
24332441

pandas/tests/indexes/timedeltas/test_timedelta.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import warnings
2+
13
import pytest
24

35
import numpy as np
@@ -145,7 +147,10 @@ def test_get_duplicates(self):
145147
idx = TimedeltaIndex(['1 day', '2 day', '2 day', '3 day', '3day',
146148
'4day'])
147149

148-
result = idx.get_duplicates()
150+
with warnings.catch_warnings(record=True):
151+
# Deprecated - see GH20239
152+
result = idx.get_duplicates()
153+
149154
ex = TimedeltaIndex(['2 day', '3day'])
150155
tm.assert_index_equal(result, ex)
151156

0 commit comments

Comments
 (0)