Skip to content

Added improvements in to_datetime Error reporting message #47995

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Aug 16, 2022
6 changes: 3 additions & 3 deletions pandas/_libs/tslib.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ cpdef array_to_datetime(
continue
elif is_raise:
raise ValueError(
f"time data {val} doesn't match format specified"
f"time data \"{val}\" at position {i} doesn't match format specified"
)
return values, tz_out

Expand All @@ -607,11 +607,11 @@ cpdef array_to_datetime(
# to check if all arguments have the same tzinfo
tz = py_dt.utcoffset()

except (ValueError, OverflowError):
except (ValueError, OverflowError) as err:
if is_coerce:
iresult[i] = NPY_NAT
continue
raise TypeError("invalid string coercion to datetime")
raise type(err)(f"invalid string coercion to datetime for \"{val}\" at position {i}")

if tz is not None:
seen_datetime_offset = True
Expand Down