Skip to content

Commit 5398783

Browse files
anmyachevvnlitvinov
authored andcommitted
fixed _convert_and_box_cache that raised ValueError: Tz-aware datetime.datetime cannot be converted to datetime64 unless utc=True
1 parent 947bd76 commit 5398783

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
@@ -605,6 +605,7 @@ def to_datetime(arg, errors='raise', dayfirst=False, yearfirst=False,
605605
elif isinstance(arg, ABCIndexClass):
606606
cache_array = _maybe_cache(arg, format, cache, convert_listlike)
607607
if not cache_array.empty:
608+
errors = 'ignore' if not utc else errors
608609
result = _convert_and_box_cache(arg, cache_array, box, errors,
609610
name=arg.name)
610611
else:
@@ -613,6 +614,7 @@ def to_datetime(arg, errors='raise', dayfirst=False, yearfirst=False,
613614
elif is_list_like(arg):
614615
cache_array = _maybe_cache(arg, format, cache, convert_listlike)
615616
if not cache_array.empty:
617+
errors = 'ignore' if not utc else errors
616618
result = _convert_and_box_cache(arg, cache_array, box, errors)
617619
else:
618620
result = convert_listlike(arg, box, format)

0 commit comments

Comments
 (0)