@@ -175,12 +175,8 @@ you can pass the ``dayfirst`` flag:
175
175
can't be parsed with the day being first it will be parsed as if
176
176
``dayfirst `` were False.
177
177
178
- .. note ::
179
- Specifying a ``format `` argument will potentially speed up the conversion
180
- considerably and explicitly specifying
181
- a format string of '%Y%m%d' takes a faster path still.
182
-
183
178
If you pass a single string to ``to_datetime ``, it returns single ``Timestamp ``.
179
+
184
180
Also, ``Timestamp `` can accept the string input.
185
181
Note that ``Timestamp `` doesn't accept string parsing option like ``dayfirst ``
186
182
or ``format ``, use ``to_datetime `` if these are required.
@@ -191,6 +187,25 @@ or ``format``, use ``to_datetime`` if these are required.
191
187
192
188
pd.Timestamp(' 2010/11/12' )
193
189
190
+ Providing a Format Argument
191
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
192
+
193
+ In addition to the required datetime string, a ``format `` argument can be passed to ensure specific parsing.
194
+ It will potentially speed up the conversion considerably.
195
+
196
+ For example:
197
+
198
+ .. ipython :: python
199
+
200
+ pd.to_datetime(' 2010/11/12' , format = ' %Y/%m/%d ' )
201
+
202
+ pd.to_datetime(' 12-11-2010 00:00' , format = ' %d -%m-%Y %H:%M' )
203
+
204
+ For more information on how to specify the ``format `` options, see https://docs.python.org/3/library/datetime.html#strftime-and-strptime-behavior.
205
+
206
+ Assembling datetime from multiple DataFrame columns
207
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
208
+
194
209
.. versionadded :: 0.18.1
195
210
196
211
You can also pass a ``DataFrame `` of integer or string columns to assemble into a ``Series `` of ``Timestamps ``.
0 commit comments