Skip to content

Commit 6c4e42d

Browse files
author
MarcoGorelli
committed
fixup doctest example
1 parent 6ecd861 commit 6c4e42d

File tree

1 file changed

+9
-18
lines changed

1 file changed

+9
-18
lines changed

pandas/core/tools/datetimes.py

+9-18
Original file line numberDiff line numberDiff line change
@@ -922,24 +922,6 @@ def to_datetime(
922922
1 2016-03-05
923923
dtype: datetime64[ns]
924924
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-
943925
Using a unix epoch time
944926
945927
>>> pd.to_datetime(1490195805, unit='s')
@@ -1016,6 +998,15 @@ def to_datetime(
1016998
Index([2020-10-25 02:00:00+02:00, 2020-10-25 04:00:00+01:00],
1017999
dtype='object')
10181000
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+
10191010
|
10201011
10211012
Setting ``utc=True`` solves most of the above issues:

0 commit comments

Comments
 (0)