Skip to content

Commit a4fb36d

Browse files
thomasqueirozbandrekwrHenryRocha
committed
BUG: pandas.to_datetime raises exception when more than 50 values needs coercion to NaT (pandas-dev#43732)
Raise proper error from objects_to_datetime64ns Co-authored-by: André Elimelek de Weber (andrekwr) <[email protected]> Co-authored-by: Henry Rocha (HenryRocha) <[email protected]>
1 parent 6b75ed6 commit a4fb36d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

pandas/core/arrays/datetimes.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2188,15 +2188,15 @@ def objects_to_datetime64ns(
21882188
allow_mixed=allow_mixed,
21892189
)
21902190
result = result.reshape(data.shape, order=order)
2191-
except ValueError as err:
2191+
except ValueError as err1:
21922192
try:
21932193
values, tz_parsed = conversion.datetime_to_datetime64(data.ravel("K"))
21942194
# If tzaware, these values represent unix timestamps, so we
21952195
# return them as i8 to distinguish from wall times
21962196
values = values.reshape(data.shape, order=order)
21972197
return values.view("i8"), tz_parsed
2198-
except (ValueError, TypeError):
2199-
raise err
2198+
except (ValueError, TypeError) as err2:
2199+
raise err2 from err1
22002200

22012201
if tz_parsed is not None:
22022202
# We can take a shortcut since the datetime64 numpy array

0 commit comments

Comments
 (0)