Skip to content

Commit 644a335

Browse files
add conditional to check ndim
1 parent f4851e5 commit 644a335

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

pandas/core/construction.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,9 @@ 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 TypeError("values must be a 1D list-like")
307310

308311
if dtype is None and isinstance(data, (ABCSeries, ABCIndex, ExtensionArray)):
309312
# Note: we exclude np.ndarray here, will do type inference on it

0 commit comments

Comments
 (0)