Skip to content

Commit ce1a759

Browse files
add conditional to check ndim
1 parent 373e75b commit ce1a759

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

pandas/core/construction.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,9 +304,6 @@ def array(
304304
raise ValueError(msg)
305305
elif isinstance(data, ABCDataFrame):
306306
raise TypeError("Cannot pass DataFrame to 'pandas.array'")
307-
elif isinstance(data, np.ndarray):
308-
if data.ndim != 1:
309-
raise ValueError("NumpyExtensionArray must be 1-dimensional")
310307

311308
if dtype is None and isinstance(data, (ABCSeries, ABCIndex, ExtensionArray)):
312309
# Note: we exclude np.ndarray here, will do type inference on it
@@ -363,6 +360,8 @@ def array(
363360
# StringArray/ArrowStringArray depending on pd.options.mode.string_storage
364361
dtype = StringDtype()
365362
cls = dtype.construct_array_type()
363+
if data.ndim != 1:
364+
raise ValueError("NumpyExtensionArray must be 1-dimensional")
366365
return cls._from_sequence(data, dtype=dtype, copy=copy)
367366

368367
elif data.dtype.kind in "iu":

0 commit comments

Comments
 (0)