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
BUG: Do not fail when parsing pydatetime objects in pd.to_datetime (#49893)
* parent 0168e27
author Antonio Ossa Guerra <[email protected]> 1666800993 -0300
committer MarcoGorelli <> 1669293453 +0000
Parse `datetime` properly in `pd.to_datetime`
When applying `pd.to_datetime` on array-like structure that contain a
`datetime.datetime` object, while using the `format` argument, a
`ValueError` is raised because the `datetime.datetime` object does not
match the expected format.
The implemented solution looks for `datetime.datetime` instances in the
`array_strptime` method. If an instance of this type is found, it's
properly handled by the new `_parse_python_datetime_object`, which
returns the expected Numpy datetime object.
Signed-off-by: Antonio Ossa Guerra <[email protected]>
* fixup
* 🏷️ typing
* ignore pylint nitpick
* better naming
* keep use-a-generator check
* use fromisoformat
* change awareness to be UTC
* Revert "use fromisoformat"
This reverts commit af272e1.
* rename input to args
Signed-off-by: Antonio Ossa Guerra <[email protected]>
Co-authored-by: Antonio Ossa Guerra <[email protected]>
Co-authored-by: MarcoGorelli <>
Copy file name to clipboardExpand all lines: doc/source/whatsnew/v2.0.0.rst
+1
Original file line number
Diff line number
Diff line change
@@ -638,6 +638,7 @@ Datetimelike
638
638
- Bug in subtracting a ``datetime`` scalar from :class:`DatetimeIndex` failing to retain the original ``freq`` attribute (:issue:`48818`)
639
639
- Bug in ``pandas.tseries.holiday.Holiday`` where a half-open date interval causes inconsistent return types from :meth:`USFederalHolidayCalendar.holidays` (:issue:`49075`)
640
640
- Bug in rendering :class:`DatetimeIndex` and :class:`Series` and :class:`DataFrame` with timezone-aware dtypes with ``dateutil`` or ``zoneinfo`` timezones near daylight-savings transitions (:issue:`49684`)
641
+
- Bug in :func:`to_datetime` was raising ``ValueError`` when parsing :class:`Timestamp` or ``datetime`` objects with non-ISO8601 ``format`` (:issue:`49298`)
0 commit comments