@@ -132,6 +132,16 @@ def array(data, # type: Sequence[object]
132
132
rather than a ``PandasArray``. This is for symmetry with the case of
133
133
timezone-aware data, which NumPy does not natively support.
134
134
135
+ >>> pd.array(['2015', '2016'], dtype='datetime64[ns]')
136
+ <DatetimeArray>
137
+ ['2015-01-01 00:00:00', '2016-01-01 00:00:00']
138
+ Length: 2, dtype: datetime64[ns]
139
+
140
+ >>> pd.array(["1H", "2H"], dtype='timedelta64[ns]')
141
+ <TimedeltaArray>
142
+ ['01:00:00', '02:00:00']
143
+ Length: 2, dtype: timedelta64[ns]
144
+
135
145
Examples
136
146
--------
137
147
If a dtype is not specified, `data` is passed through to
@@ -257,7 +267,7 @@ def array(data, # type: Sequence[object]
257
267
# so that a DatetimeArray is returned.
258
268
if is_datetime64_ns_dtype (dtype ):
259
269
return DatetimeArray ._from_sequence (data , dtype = dtype , copy = copy )
260
- if is_timedelta64_ns_dtype (dtype ):
270
+ elif is_timedelta64_ns_dtype (dtype ):
261
271
return TimedeltaArray ._from_sequence (data , dtype = dtype , copy = copy )
262
272
263
273
result = PandasArray ._from_sequence (data , dtype = dtype , copy = copy )
0 commit comments