Skip to content

Commit 5d194de

Browse files
committed
Use quicker unique check
1 parent 2da9527 commit 5d194de

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

pandas/core/tools/datetimes.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,10 @@ def _maybe_convert_cache(arg, cache, box, format, name=None, tz=tz):
338338
None if the conversion failed
339339
"""
340340
if cache and is_list_like(arg) and len(arg) >= 1000:
341-
unique_dates = algorithms.unique(arg)
342-
if len(unique_dates) != len(arg):
341+
# Perform a quicker unique check
342+
from pandas import Index
343+
if not Index(arg).is_unique:
344+
unique_dates = algorithms.unique(arg)
343345
from pandas import Series
344346
cache_dates = _convert_listlike(unique_dates, True, format,
345347
tz=tz)

0 commit comments

Comments
 (0)