Skip to content

Commit 3ac1f04

Browse files
committed
fixup
1 parent 20284cc commit 3ac1f04

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

pandas/core/arrays/array_.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,16 @@ def array(data, # type: Sequence[object]
132132
rather than a ``PandasArray``. This is for symmetry with the case of
133133
timezone-aware data, which NumPy does not natively support.
134134
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+
135145
Examples
136146
--------
137147
If a dtype is not specified, `data` is passed through to
@@ -257,7 +267,7 @@ def array(data, # type: Sequence[object]
257267
# so that a DatetimeArray is returned.
258268
if is_datetime64_ns_dtype(dtype):
259269
return DatetimeArray._from_sequence(data, dtype=dtype, copy=copy)
260-
if is_timedelta64_ns_dtype(dtype):
270+
elif is_timedelta64_ns_dtype(dtype):
261271
return TimedeltaArray._from_sequence(data, dtype=dtype, copy=copy)
262272

263273
result = PandasArray._from_sequence(data, dtype=dtype, copy=copy)

0 commit comments

Comments
 (0)