Skip to content

Commit 7405509

Browse files
author
MarcoGorelli
committed
add whatsnew note
1 parent d8b3730 commit 7405509

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

doc/source/whatsnew/v1.6.0.rst

+33
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,39 @@ Optional libraries below the lowest tested version may still work, but are not c
112112

113113
See :ref:`install.dependencies` and :ref:`install.optional_dependencies` for more.
114114

115+
Datetimes are now parsed with a consistent format
116+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
117+
118+
:func:`to_datetime` now parses dates with a consistent format, which is guessed from the first non-NA value
119+
(unless ``format`` is specified). Previously, it would've guessed the format for each element individually.
120+
121+
*Old behavior*:
122+
123+
.. code-block:: ipython
124+
125+
In [1]: ser = pd.Series(['13-01-2000', '12-01-2000'])
126+
In [2]: pd.to_datetime(ser)
127+
Out[2]:
128+
0 2000-01-13
129+
1 2000-12-01
130+
dtype: datetime64[ns]
131+
132+
*New behavior*:
133+
134+
.. ipython:: python
135+
:okwarning:
136+
137+
ser = pd.Series(['13-01-2000', '12-01-2000'])
138+
pd.to_datetime(ser)
139+
140+
Note that this affects :func:`read_csv` as well.
141+
142+
If you still need to parse dates with inconsistent formats, you'll need to apply :func:`to_datetime`
143+
to each element individually, e.g. ::
144+
145+
ser = pd.Series(['13-01-2000', '12 January 2000'])
146+
ser.apply(pd.to_datetime)
147+
115148
.. _whatsnew_160.api_breaking.other:
116149

117150
Other API changes

0 commit comments

Comments
 (0)