File tree Expand file tree Collapse file tree 2 files changed +2
-3
lines changed
Expand file tree Collapse file tree 2 files changed +2
-3
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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 :
You can’t perform that action at this time.
0 commit comments