Skip to content

Commit edaeca2

Browse files
committed
doc update for pandas-dev#47134
1 parent 298dac3 commit edaeca2

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

pandas/core/tools/datetimes.py

+24-2
Original file line numberDiff line numberDiff line change
@@ -777,11 +777,18 @@ def to_datetime(
777777
#time-zone-handling>`_.
778778
779779
format : str, default None
780-
The strftime to parse time, e.g. :const:`"%d/%m/%Y"`. Note that
781-
:const:`"%f"` will parse all the way up to nanoseconds. See
780+
The strftime to parse time, e.g. :const:`"%d/%m/%Y"`. See
782781
`strftime documentation
783782
<https://docs.python.org/3/library/datetime.html
784783
#strftime-and-strptime-behavior>`_ for more information on choices.
784+
785+
- Note that :const:`"%f"` will parse all the way
786+
up to nanoseconds.
787+
788+
- Note that :const:`"%S"` without :const:`"%f"` will capture all the way
789+
up to nanoseconds if present as decimal places, but will also handle
790+
the case where the number of seconds is an integer.
791+
785792
exact : bool, default True
786793
Control how `format` is used:
787794
@@ -950,6 +957,21 @@ def to_datetime(
950957
DatetimeIndex(['1960-01-02', '1960-01-03', '1960-01-04'],
951958
dtype='datetime64[ns]', freq=None)
952959
960+
**Exceptions to strptime behavior**
961+
962+
:const:`"%f"` will parse all the way up to nanoseconds.
963+
964+
>>> pd.to_datetime('2018-10-26 12:00:00.0000000011',
965+
... format='%Y-%m-%d %H:%M:%S.%f')
966+
Timestamp('2018-10-26 12:00:00.000000001')
967+
968+
:const:`"%S"` without :const:`"%f"` will capture all the way
969+
up to nanoseconds if present as decimal places.
970+
971+
>>> pd.to_datetime('2017-03-22 15:16:45.433502912',
972+
... format='%Y-%m-%d %H:%M:%S')
973+
Timestamp('2017-03-22 15:16:45.433502912')
974+
953975
**Non-convertible date/times**
954976
955977
If a date does not meet the `timestamp limitations

0 commit comments

Comments
 (0)