5757)
5858from pandas .core .arrays import (
5959 Categorical ,
60+ DatetimeArray ,
6061 ExtensionArray ,
6162 TimedeltaArray ,
6263)
@@ -515,7 +516,9 @@ def treat_as_nested(data) -> bool:
515516
516517
517518def _prep_ndarray (values , copy : bool = True ) -> np .ndarray :
518- if isinstance (values , TimedeltaArray ):
519+ if isinstance (values , TimedeltaArray ) or (
520+ isinstance (values , DatetimeArray ) and values .tz is None
521+ ):
519522 # On older numpy, np.asarray below apparently does not call __array__,
520523 # so nanoseconds get dropped.
521524 values = values ._ndarray
@@ -541,15 +544,12 @@ def convert(v):
541544 # we could have a 1-dim or 2-dim list here
542545 # this is equiv of np.asarray, but does object conversion
543546 # and platform dtype preservation
544- try :
545- if is_list_like (values [0 ]):
546- values = np .array ([convert (v ) for v in values ])
547- elif isinstance (values [0 ], np .ndarray ) and values [0 ].ndim == 0 :
548- # GH#21861
549- values = np .array ([convert (v ) for v in values ])
550- else :
551- values = convert (values )
552- except (ValueError , TypeError ):
547+ if is_list_like (values [0 ]):
548+ values = np .array ([convert (v ) for v in values ])
549+ elif isinstance (values [0 ], np .ndarray ) and values [0 ].ndim == 0 :
550+ # GH#21861
551+ values = np .array ([convert (v ) for v in values ])
552+ else :
553553 values = convert (values )
554554
555555 else :
0 commit comments