We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent bc106df commit c30dd74Copy full SHA for c30dd74
pandas/core/construction.py
@@ -807,8 +807,13 @@ def _try_cast(
807
)
808
809
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)
+ if is_ndarray:
+ arr = cast(np.ndarray, arr)
812
+ shape = arr.shape
813
+ if arr.ndim == 2 and shape[1] == 1:
814
+ # GH#60081: DataFrame Constructor converts 1D data to array of
815
+ # shape (N, 1), but maybe_cast_to_datetime assumes 1D input
816
+ return maybe_cast_to_datetime(arr[:, 0], dtype).reshape(shape)
817
return maybe_cast_to_datetime(arr, dtype)
818
819
# GH#15832: Check if we are requesting a numeric dtype and
0 commit comments