Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions doc/source/timeseries.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Copy link
Member

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)


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.
Expand All @@ -191,6 +187,25 @@ or ``format``, use ``to_datetime`` if these are required.

pd.Timestamp('2010/11/12')

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 a section ref tag here as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have put a reference to the pd.Timestamp documentation as above and pushed.

Providing a Format Argument
~~~~~~~~~~~~~~~~~~~~~~~~~~~

In addition to the required datetime string, a ``format`` argument can be passed to ensure specific parsing.
It will potentially speed up the conversion considerably.

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
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 format the link

`text-to-display <linktext>`__

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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``.
Expand Down