Skip to content

Commit 27fdfac

Browse files
committed
replace to_datetime call with internal conversion func
1 parent 9e6e2a7 commit 27fdfac

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

pandas/core/dtypes/cast.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -913,10 +913,17 @@ def try_datetime(v):
913913
# we might have a sequence of the same-datetimes with tz's
914914
# if so coerce to a DatetimeIndex; if they are not the same,
915915
# then these stay as object dtype
916+
917+
# GH19671
918+
# replaced to_datetime call with
919+
# tslibs.conversion.datetime_to_datetime64
920+
# in order to avoid changes to public to_datetime API
916921
try:
917-
from pandas import to_datetime
918-
# GH19671
919-
return to_datetime(v, require_iso8601=True)
922+
from pandas._libs.tslibs import conversion
923+
from pandas.core.indexes.datetimes import DatetimeIndex
924+
925+
values, tz = conversion.datetime_to_datetime64(v)
926+
return DatetimeIndex._simple_new(values, tz=tz)
920927
except Exception:
921928
pass
922929

0 commit comments

Comments
 (0)