Skip to content

Commit 4dbb8ec

Browse files
committed
Added example to docs
1 parent 50311ce commit 4dbb8ec

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

pandas/tseries/tools.py

+13
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,19 @@ def to_datetime(arg, errors='raise', dayfirst=False, yearfirst=False,
275275
99 2000-04-09
276276
Length: 100, dtype: datetime64[ns]
277277
278+
Infer the format from the first entry
279+
280+
>>> pd.to_datetime(df.month + '/' + df.day + '/' + df.year,
281+
infer_datetime_format=True)
282+
0 2000-01-01
283+
1 2000-01-02
284+
...
285+
98 2000-04-08
286+
99 2000-04-09
287+
288+
This gives the same results as omitting the `infer_datetime_format=True`,
289+
but is much faster.
290+
278291
Date that does not meet timestamp limitations:
279292
280293
>>> pd.to_datetime('13000101', format='%Y%m%d')

0 commit comments

Comments
 (0)