You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Datetime parsing (PDEP-4): allow mixture of ISO formatted strings (#50939)
* allow format iso8601
* fixup tests
* 🏷️ typing
* remove duplicate code
* improve message, use if-statement
* note that exact has no effect if format=iso8601
* point to format=ISO8601 in error message
* allow format="mixed"
* link to iso wiki page
* minor fixups
* double backticks -> single, suggest passing format
* use format=mixed instead of apply in example;
---------
Co-authored-by: MarcoGorelli <>
Co-authored-by: Matthew Roeschke <[email protected]>
Copy file name to clipboardExpand all lines: doc/source/whatsnew/v2.0.0.rst
+10-3
Original file line number
Diff line number
Diff line change
@@ -311,6 +311,8 @@ Other enhancements
311
311
- Added :meth:`DatetimeIndex.as_unit` and :meth:`TimedeltaIndex.as_unit` to convert to different resolutions; supported resolutions are "s", "ms", "us", and "ns" (:issue:`50616`)
312
312
- Added :meth:`Series.dt.unit` and :meth:`Series.dt.as_unit` to convert to different resolutions; supported resolutions are "s", "ms", "us", and "ns" (:issue:`51223`)
313
313
- Added new argument ``dtype`` to :func:`read_sql` to be consistent with :func:`read_sql_query` (:issue:`50797`)
314
+
- :func:`to_datetime` now accepts ``"ISO8601"`` as an argument to ``format``, which will match any ISO8601 string (but possibly not identically-formatted) (:issue:`50411`)
315
+
- :func:`to_datetime` now accepts ``"mixed"`` as an argument to ``format``, which will infer the format for each element individually (:issue:`50972`)
314
316
- Added new argument ``engine`` to :func:`read_json` to support parsing JSON with pyarrow by specifying ``engine="pyarrow"`` (:issue:`48893`)
315
317
- Added support for SQLAlchemy 2.0 (:issue:`40686`)
316
318
- :class:`Index` set operations :meth:`Index.union`, :meth:`Index.intersection`, :meth:`Index.difference`, and :meth:`Index.symmetric_difference` now support ``sort=True``, which will always return a sorted result, unlike the default ``sort=None`` which does not sort in some cases (:issue:`25151`)
@@ -738,11 +740,16 @@ In the past, :func:`to_datetime` guessed the format for each element independent
738
740
739
741
Note that this affects :func:`read_csv` as well.
740
742
741
-
If you still need to parse dates with inconsistent formats, you'll need to apply :func:`to_datetime`
742
-
to each element individually, e.g. ::
743
+
If you still need to parse dates with inconsistent formats, you can use
0 commit comments