@@ -922,24 +922,6 @@ def to_datetime(
922
922
1 2016-03-05
923
923
dtype: datetime64[ns]
924
924
925
- Passing ``infer_datetime_format=True`` can often-times speedup a parsing
926
- if its not an ISO8601 format exactly, but in a regular format.
927
-
928
- >>> s = pd.Series(['3/11/2000', '3/12/2000', '3/13/2000'] * 1000)
929
- >>> s.head()
930
- 0 3/11/2000
931
- 1 3/12/2000
932
- 2 3/13/2000
933
- 3 3/11/2000
934
- 4 3/12/2000
935
- dtype: object
936
-
937
- >>> %timeit pd.to_datetime(s, infer_datetime_format=True) # doctest: +SKIP
938
- 100 loops, best of 3: 10.4 ms per loop
939
-
940
- >>> %timeit pd.to_datetime(s, infer_datetime_format=False) # doctest: +SKIP
941
- 1 loop, best of 3: 471 ms per loop
942
-
943
925
Using a unix epoch time
944
926
945
927
>>> pd.to_datetime(1490195805, unit='s')
@@ -1016,6 +998,15 @@ def to_datetime(
1016
998
Index([2020-10-25 02:00:00+02:00, 2020-10-25 04:00:00+01:00],
1017
999
dtype='object')
1018
1000
1001
+ - A mix of timezone-aware and timezone-naive inputs is converted to
1002
+ a timezone-aware :class:`DatetimeIndex` if the offsets of the timezone-aware
1003
+ are constant:
1004
+
1005
+ >>> from datetime import datetime
1006
+ >>> pd.to_datetime(["2020-01-01 01:00:00-01:00", datetime(2020, 1, 1, 3, 0)])
1007
+ DatetimeIndex(['2020-01-01 01:00:00-01:00', '2020-01-01 02:00:00-01:00'],
1008
+ dtype='datetime64[ns, pytz.FixedOffset(-60)]', freq=None)
1009
+
1019
1010
|
1020
1011
1021
1012
Setting ``utc=True`` solves most of the above issues:
0 commit comments