Skip to content

Commit 5d0ee97

Browse files
author
MarcoGorelli
committed
wip
2 parents 772c274 + 8fad317 commit 5d0ee97

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

doc/source/whatsnew/v2.0.0.rst

+2
Original file line numberDiff line numberDiff line change
@@ -790,6 +790,8 @@ Datetimelike
790790
- Bug in :func:`to_datetime` was raising ``ValueError`` when parsing :class:`Timestamp`, ``datetime.datetime``, ``datetime.date``, or ``np.datetime64`` objects when non-ISO8601 ``format`` was passed (:issue:`49298`, :issue:`50036`)
791791
- Bug in :func:`to_datetime` was raising ``ValueError`` when parsing empty string and non-ISO8601 format was passed. Now, empty strings will be parsed as :class:`NaT`, for compatibility with how is done for ISO8601 formats (:issue:`50251`)
792792
- Bug in :class:`Timestamp` was showing ``UserWarning``, which was not actionable by users, when parsing non-ISO8601 delimited date strings (:issue:`50232`)
793+
- Bug in :class:`Timestamp` was showing ``UserWarning`` which was not actionable by users (:issue:`50232`)
794+
- Bug in :func:`to_datetime` was raising ``ValueError`` when parsing empty string and non-ISO8601 format was passed. Now, empty strings will be parsed as :class:`NaT`, for compatibility with how is done for ISO8601 formats (:issue:`50251`)
793795
-
794796

795797
Timedelta

pandas/tests/tools/test_to_datetime.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -1826,7 +1826,10 @@ def test_dataframe_mixed(self, cache):
18261826
def test_dataframe_float(self, cache):
18271827
# float
18281828
df = DataFrame({"year": [2000, 2001], "month": [1.5, 1], "day": [1, 1]})
1829-
msg = "cannot assemble the datetimes: unconverted data remains: 1"
1829+
msg = (
1830+
'cannot assemble the datetimes: time data "20000151" at position 0 '
1831+
'doesn\'t match format "%Y%m%d"'
1832+
)
18301833
with pytest.raises(ValueError, match=msg):
18311834
to_datetime(df, cache=cache)
18321835

@@ -3006,6 +3009,7 @@ def test_na_to_datetime(nulls_fixture, klass):
30063009

30073010

30083011
@pytest.mark.parametrize("errors", ["raise", "coerce", "ignore"])
3012+
<<<<<<< HEAD
30093013
@pytest.mark.parametrize(
30103014
"args, format",
30113015
[
@@ -3017,6 +3021,12 @@ def test_na_to_datetime(nulls_fixture, klass):
30173021
def test_empty_string_datetime(errors, args, format):
30183022
# GH13044, GH50251
30193023
td = Series(args)
3024+
=======
3025+
def test_empty_string_datetime_coerce_format(errors):
3026+
# GH13044, GH50251
3027+
td = Series(["03/24/2016", "03/25/2016", ""])
3028+
format = "%m/%d/%Y"
3029+
>>>>>>> 8fad3173b2aca474c43af653dba9da86cbc421d4
30203030

30213031
# coerce empty string to pd.NaT
30223032
result = to_datetime(td, format=format, errors=errors)

0 commit comments

Comments
 (0)