Skip to content

Commit d059d44

Browse files
committed
Pass most tests
1 parent 9486df3 commit d059d44

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

pandas/core/tools/datetimes.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,17 @@ def _maybe_cache(arg, format, cache, tz, _convert_listlike):
4949
cache_array = Series(cache_dates, index=unique_dates)
5050
return cache_array
5151

52-
def _convert_and_box_cache(arg, cache_array, box, name=None):
52+
def _convert_and_box_cache(arg, cache_array, box, errors, tz, name=None):
5353
"""Convert array of dates with a cache and box the result"""
5454
from pandas import Series
5555
from pandas.core.indexes.datetimes import DatetimeIndex
5656
result = Series(arg).map(cache_array)
5757
if box:
58-
result = DatetimeIndex(result, name=name)
59-
else:
60-
result = result.values
58+
if errors == 'ignore':
59+
from pandas import Index
60+
result = Index(result)
61+
else:
62+
result = DatetimeIndex(result, tz=tz, name=name)
6163
return result
6264

6365
def to_datetime(arg, errors='raise', dayfirst=False, yearfirst=False,
@@ -410,14 +412,14 @@ def _convert_listlike(arg, box, format, name=None, tz=tz):
410412
elif isinstance(arg, ABCIndexClass):
411413
cache_array = _maybe_cache(arg, format, cache, tz, _convert_listlike)
412414
if not cache_array.empty:
413-
result = _convert_and_box_cache(arg, cache_array, box,
415+
result = _convert_and_box_cache(arg, cache_array, box, errors, tz,
414416
name=arg.name)
415417
else:
416418
result = _convert_listlike(arg, box, format, name=arg.name)
417419
elif is_list_like(arg):
418420
cache_array = _maybe_cache(arg, format, cache, tz, _convert_listlike)
419421
if not cache_array.empty:
420-
result = _convert_and_box_cache(arg, cache_array, box)
422+
result = _convert_and_box_cache(arg, cache_array, box, errors, tz)
421423
else:
422424
result = _convert_listlike(arg, box, format)
423425
else:

0 commit comments

Comments
 (0)