Skip to content

Commit b69f82e

Browse files
update fix
1 parent a0c7051 commit b69f82e

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

pandas/core/dtypes/cast.py

+2
Original file line numberDiff line numberDiff line change
@@ -1038,6 +1038,8 @@ def maybe_cast_to_datetime(value, dtype, errors='raise'):
10381038
.tz_convert(dtype.tz))
10391039
elif is_timedelta64:
10401040
value = to_timedelta(value, errors=errors)._values
1041+
except OutOfBoundsDatetime:
1042+
raise
10411043
except (AttributeError, ValueError, TypeError):
10421044
pass
10431045

pandas/core/internals/construction.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -702,8 +702,8 @@ def _try_cast(arr, take_fast_path, dtype, copy, raise_cast_failure):
702702
subarr = construct_1d_ndarray_preserving_na(subarr, dtype,
703703
copy=copy)
704704
except OutOfBoundsDatetime:
705-
if raise_cast_failure:
706-
raise
705+
# in case of out of bound datetime64 -> always raise
706+
raise
707707
except (ValueError, TypeError):
708708
if is_categorical_dtype(dtype):
709709
# We *do* allow casting to categorical, since we know

0 commit comments

Comments
 (0)