Skip to content

Commit 387851d

Browse files
committed
adding position info & updated testcase
1 parent 3c2a833 commit 387851d

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

pandas/_libs/tslib.pyx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -824,7 +824,8 @@ cdef _array_to_datetime_object(
824824
yearfirst=yearfirst)
825825
pydatetime_to_dt64(oresult[i], &dts)
826826
check_dts_bounds(&dts)
827-
except (ValueError, OverflowError):
827+
except (ValueError, OverflowError) as ex:
828+
ex.args = (str(ex) + f" present at position {i}", )
828829
if is_coerce:
829830
oresult[i] = <object>NaT
830831
continue

pandas/tests/tools/test_to_datetime.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2593,7 +2593,7 @@ def test_invalid_origins_tzinfo(self):
25932593

25942594
def test_incorrect_value_exception(self):
25952595
# GH47495
2596-
with pytest.raises(ValueError, match="Unknown string format: today"):
2596+
with pytest.raises(ValueError, match="Unknown string format: yesterday present at position 1"):
25972597
to_datetime(["today", "yesterday"])
25982598

25992599
@pytest.mark.parametrize("format", [None, "%Y-%m-%d %H:%M:%S"])

0 commit comments

Comments
 (0)