Skip to content

Commit 5f2a8f0

Browse files
committed
fixed _convert_and_box_cache that raised ValueError: Tz-aware datetime.datetime cannot be converted to datetime64 unless utc=True
1 parent 057b242 commit 5f2a8f0

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

pandas/core/tools/datetimes.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,7 @@ def to_datetime(arg, errors='raise', dayfirst=False, yearfirst=False,
604604
elif isinstance(arg, ABCIndexClass):
605605
cache_array = _maybe_cache(arg, format, cache, convert_listlike)
606606
if not cache_array.empty:
607+
errors = 'ignore' if not utc else errors
607608
result = _convert_and_box_cache(arg, cache_array, box, errors,
608609
name=arg.name)
609610
else:
@@ -612,6 +613,7 @@ def to_datetime(arg, errors='raise', dayfirst=False, yearfirst=False,
612613
elif is_list_like(arg):
613614
cache_array = _maybe_cache(arg, format, cache, convert_listlike)
614615
if not cache_array.empty:
616+
errors = 'ignore' if not utc else errors
615617
result = _convert_and_box_cache(arg, cache_array, box, errors)
616618
else:
617619
result = convert_listlike(arg, box, format)

0 commit comments

Comments
 (0)