-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
DOC: to_datetime format argument examples #17412
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -175,12 +175,8 @@ you can pass the ``dayfirst`` flag: | |
can't be parsed with the day being first it will be parsed as if | ||
``dayfirst`` were False. | ||
|
||
.. note:: | ||
Specifying a ``format`` argument will potentially speed up the conversion | ||
considerably and on versions later then 0.13.0 explicitly specifying | ||
a format string of '%Y%m%d' takes a faster path still. | ||
|
||
If you pass a single string to ``to_datetime``, it returns single ``Timestamp``. | ||
|
||
Also, ``Timestamp`` can accept the string input. | ||
Note that ``Timestamp`` doesn't accept string parsing option like ``dayfirst`` | ||
or ``format``, use ``to_datetime`` if these are required. | ||
|
@@ -191,6 +187,25 @@ or ``format``, use ``to_datetime`` if these are required. | |
|
||
pd.Timestamp('2010/11/12') | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you add a section ref tag here as well. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have put a reference to the |
||
Providing a Format Argument | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
A specific ``format`` argument can be passed in addition to the datetime string. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would add something like "to ensure a specific and consistent parsing of the string" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you also add a blankline between the title and the first sentence ? |
||
It will potentially speed up the conversion considerably and on versions later | ||
then 0.13.0. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The "and on versionse later than 0.13.0" can be removed as well |
||
|
||
For example: | ||
|
||
.. ipython:: python | ||
|
||
pd.to_datetime('2010/11/12', format='%Y/%m/%d') | ||
|
||
pd.to_datetime('12-11-2010 00:00', format='%d-%m-%Y %H:%M') | ||
|
||
For further format options see: https://docs.python.org/3/library/datetime.html#strftime-and-strptime-behavior | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you format the link
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have put the linktext whithin the arrows and pushed. Hope that'll do There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After going through the contribution docs. I rebased and pushed the branch. Sorry for the inconvenience, that I first pushed to master. |
||
|
||
Assembling datetime from multiple DataFrame columns | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
.. versionadded:: 0.18.1 | ||
|
||
You can also pass a ``DataFrame`` of integer or string columns to assemble into a ``Series`` of ``Timestamps``. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jreback we removed this part, as it is not a very clear sentence, and also does not seem to be true (#17410)