Skip to content

Commit 11a9a7e

Browse files
committed
Update
1 parent bc106df commit 11a9a7e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

pandas/core/construction.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -807,8 +807,12 @@ 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)
810+
if is_ndarray:
811+
arr = cast(np.ndarray, arr)
812+
if arr.ndim == 2 and arr.shape[1] == 1:
813+
# GH#60081: DataFrame Constructor converts 1D data to array of
814+
# shape (N, 1), but maybe_cast_to_datetime assumes 1D input
815+
return maybe_cast_to_datetime(arr[:, 0], dtype).reshape(arr.shape)
812816
return maybe_cast_to_datetime(arr, dtype)
813817

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

0 commit comments

Comments
 (0)