Skip to content

Commit 0870ad3

Browse files
committed
WIP some to_datetime docs additions
1 parent 734d018 commit 0870ad3

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

doc/source/timeseries.rst

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,37 @@ scalar values and ``PeriodIndex`` for sequences of spans. Better support for
110110
irregular intervals with arbitrary start and end points are forth-coming in
111111
future releases.
112112

113+
114+
.. _timeseries.converting:
115+
116+
Converting to Timestamps
117+
------------------------
118+
119+
To convert a list or Series of datetimes or strings (or a mixture, or NAs),
120+
you can use the ``to_datetime`` function:
121+
122+
.. ipython:: python
123+
124+
pd.to_datetime(['Jul 31, 2009', '2010-01-10'])
125+
126+
pd.to_datetime(['2005/11/23', '2010.12.31''])
127+
128+
If you use dates start with the dayfirst (European style), you can pass
129+
the dayfirst flag:
130+
131+
.. ipython:: python
132+
133+
to_datetime(['12-13-2012'], dayfirst=True)
134+
135+
*There is a known bug that this falls back to not dayfirst if there are
136+
inconsistent date formats.*
137+
138+
Pass ``coerce=True`` to convert data to ``NaT`` (not a time):
139+
140+
.. ipython:: python
141+
142+
pd.to_datetime(['2009-07-31', 'asd'], coerce=True)
143+
113144
.. _timeseries.daterange:
114145
115146
Generating Ranges of Timestamps

0 commit comments

Comments
 (0)