57
57
)
58
58
from pandas .core .arrays import (
59
59
Categorical ,
60
+ DatetimeArray ,
60
61
ExtensionArray ,
61
62
TimedeltaArray ,
62
63
)
@@ -515,7 +516,9 @@ def treat_as_nested(data) -> bool:
515
516
516
517
517
518
def _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
+ ):
519
522
# On older numpy, np.asarray below apparently does not call __array__,
520
523
# so nanoseconds get dropped.
521
524
values = values ._ndarray
@@ -541,15 +544,12 @@ def convert(v):
541
544
# we could have a 1-dim or 2-dim list here
542
545
# this is equiv of np.asarray, but does object conversion
543
546
# 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 :
553
553
values = convert (values )
554
554
555
555
else :
0 commit comments