Skip to content

Commit d93d5b2

Browse files
committed
Move upper level
1 parent 0627217 commit d93d5b2

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

pandas/core/construction.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -807,6 +807,8 @@ def _try_cast(
807807
)
808808

809809
elif dtype.kind in "mM":
810+
if is_ndarray and arr.ndim == 2 and arr.shape[1] == 1:
811+
return maybe_cast_to_datetime(arr.ravel(), dtype).reshape(arr.shape)
810812
return maybe_cast_to_datetime(arr, dtype)
811813

812814
# GH#15832: Check if we are requesting a numeric dtype and

pandas/core/dtypes/cast.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1225,9 +1225,6 @@ def maybe_cast_to_datetime(
12251225
_ensure_nanosecond_dtype(dtype)
12261226

12271227
if lib.is_np_dtype(dtype, "m"):
1228-
if isinstance(value, np.ndarray) and value.ndim == 2 and value.shape[1] == 1:
1229-
res = TimedeltaArray._from_sequence(value.ravel(), dtype=dtype)
1230-
return res.reshape(value.shape)
12311228
res = TimedeltaArray._from_sequence(value, dtype=dtype)
12321229
return res
12331230
else:

0 commit comments

Comments
 (0)