@@ -777,11 +777,18 @@ def to_datetime(
777
777
#time-zone-handling>`_.
778
778
779
779
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
782
781
`strftime documentation
783
782
<https://docs.python.org/3/library/datetime.html
784
783
#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
+
785
792
exact : bool, default True
786
793
Control how `format` is used:
787
794
@@ -950,6 +957,21 @@ def to_datetime(
950
957
DatetimeIndex(['1960-01-02', '1960-01-03', '1960-01-04'],
951
958
dtype='datetime64[ns]', freq=None)
952
959
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
+
953
975
**Non-convertible date/times**
954
976
955
977
If a date does not meet the `timestamp limitations
0 commit comments