@@ -777,11 +777,19 @@ 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
- #strftime-and-strptime-behavior>`_ for more information on choices.
783
+ #strftime-and-strptime-behavior>`_ for more information on choices, though
784
+ note the following differences:
785
+
786
+ - :const:`"%f"` will parse all the way
787
+ up to nanoseconds;
788
+
789
+ - :const:`"%S"` without :const:`"%f"` will capture all the way
790
+ up to nanoseconds if present as decimal places, and will also handle
791
+ the case where the number of seconds is an integer.
792
+
785
793
exact : bool, default True
786
794
Control how `format` is used:
787
795
@@ -950,6 +958,21 @@ def to_datetime(
950
958
DatetimeIndex(['1960-01-02', '1960-01-03', '1960-01-04'],
951
959
dtype='datetime64[ns]', freq=None)
952
960
961
+ **Differences with strptime behavior**
962
+
963
+ :const:`"%f"` will parse all the way up to nanoseconds.
964
+
965
+ >>> pd.to_datetime('2018-10-26 12:00:00.0000000011',
966
+ ... format='%Y-%m-%d %H:%M:%S.%f')
967
+ Timestamp('2018-10-26 12:00:00.000000001')
968
+
969
+ :const:`"%S"` without :const:`"%f"` will capture all the way
970
+ up to nanoseconds if present as decimal places.
971
+
972
+ >>> pd.to_datetime('2017-03-22 15:16:45.433502912',
973
+ ... format='%Y-%m-%d %H:%M:%S')
974
+ Timestamp('2017-03-22 15:16:45.433502912')
975
+
953
976
**Non-convertible date/times**
954
977
955
978
If a date does not meet the `timestamp limitations
0 commit comments