From 31d28362d8f4834ddf2228e282db12c2c0e663f6 Mon Sep 17 00:00:00 2001 From: Philipp Hanemann Date: Fri, 1 Sep 2017 12:46:28 +0200 Subject: [PATCH 1/4] DOC: to_datetime format argument examples --- doc/source/timeseries.rst | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/doc/source/timeseries.rst b/doc/source/timeseries.rst index ce4a920ad77b5..5223aa6ee0312 100644 --- a/doc/source/timeseries.rst +++ b/doc/source/timeseries.rst @@ -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') +Providing a Format Argument +~~~~~~~~~~~~~~~~~~~~~~~~~~~ +A specific ``format`` argument can be passed in addition to the datetime string. +It will potentially speed up the conversion considerably and on versions later +then 0.13.0. + +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 + +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``. From 251e7b839023b243e5e231936507a661902c019e Mon Sep 17 00:00:00 2001 From: Philipp Hanemann Date: Fri, 1 Sep 2017 15:31:36 +0200 Subject: [PATCH 2/4] typos --- doc/source/timeseries.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/source/timeseries.rst b/doc/source/timeseries.rst index 5223aa6ee0312..4357bd27fedae 100644 --- a/doc/source/timeseries.rst +++ b/doc/source/timeseries.rst @@ -189,9 +189,9 @@ or ``format``, use ``to_datetime`` if these are required. Providing a Format Argument ~~~~~~~~~~~~~~~~~~~~~~~~~~~ -A specific ``format`` argument can be passed in addition to the datetime string. -It will potentially speed up the conversion considerably and on versions later -then 0.13.0. + +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: From e258ee9cd581f7f9572963a6adea70dd8aabd7c3 Mon Sep 17 00:00:00 2001 From: Philipp Hanemann Date: Fri, 8 Sep 2017 14:37:31 +0200 Subject: [PATCH 3/4] Timestamp ref tag --- doc/source/timeseries.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/source/timeseries.rst b/doc/source/timeseries.rst index 4357bd27fedae..4f0bd249f7590 100644 --- a/doc/source/timeseries.rst +++ b/doc/source/timeseries.rst @@ -187,6 +187,8 @@ or ``format``, use ``to_datetime`` if these are required. pd.Timestamp('2010/11/12') +For further `Timestamp` argument options see: + Providing a Format Argument ~~~~~~~~~~~~~~~~~~~~~~~~~~~ From 17e48ee000635a1f8c02fcdc50a94358d14484d9 Mon Sep 17 00:00:00 2001 From: Philipp Hanemann Date: Fri, 8 Sep 2017 14:53:25 +0200 Subject: [PATCH 4/4] request for formatting --- doc/source/timeseries.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/timeseries.rst b/doc/source/timeseries.rst index 4f0bd249f7590..9fdf28dbb5b5e 100644 --- a/doc/source/timeseries.rst +++ b/doc/source/timeseries.rst @@ -203,7 +203,7 @@ For example: 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 +For further `to_datetime` format options see: Assembling datetime from multiple DataFrame columns ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~