Skip to content

Commit 4fd428f

Browse files
BUG: raise TypeError when array is not all scalar in pandas.array
1 parent 59aaa8e commit 4fd428f

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

pandas/core/construction.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,8 +323,7 @@ def array(
323323

324324
# to avoid returning an array of string representation of objects.
325325
if dtype == StringDtype():
326-
ndarr = np.array(data)
327-
if ndarr.ndim != 1:
326+
if any(not lib.is_scalar(i) for i in data):
328327
raise TypeError("Values must be a 1D list-like")
329328

330329
if isinstance(dtype, ExtensionDtype):

0 commit comments

Comments
 (0)