Skip to content

DOC: how to_datetime %S differs from strptime #47164

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions pandas/core/tools/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -773,8 +773,14 @@ def to_datetime(

format : str, default None
The strftime to parse time, e.g. :const:`"%d/%m/%Y"`. Note that
:const:`"%f"` will parse all the way up to nanoseconds. See
`strftime documentation
:const:`"%S"` without :const:`"%f"` will capture fractional
seconds up to nanoseconds, Note that :const:`"%f"` will parse
up to nanoseconds.
:const:`"%S"` without :const:`"%f"` will capture up to
nanoseconds if present as decimal places, but
will also handle the case where the number of seconds is an
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add an example which illustrates this case (or both)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If u don't mind, Can u help me with how I can add an example?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to add another section in the same docstring. See this document: https://numpydoc.readthedocs.io/en/latest/format.html#examples

Note that the order of sections is important. You can check other docstrings in the pandas docs for samples, and to check which data we usually use...

Also, the CI is red because of black. You can run black before committing, and check the contributing docs for further information: https://pandas.pydata.org/pandas-docs/stable/development/contributing.html

integer.
See `strftime documentation
<https://docs.python.org/3/library/datetime.html
#strftime-and-strptime-behavior>`_ for more information on choices.
exact : bool, default True
Expand Down