Skip to content

Commit 6cfce8a

Browse files
authored
nested list multiIndex fix (pandas-dev#14467)
1 parent bdb4a08 commit 6cfce8a

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

pandas/core/internals/construction.py

+10
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,16 @@ def _convert_object_array(content, columns, coerce_float=False, dtype=None):
576576
else:
577577
if len(columns) != len(content): # pragma: no cover
578578
# caller's responsibility to check for this...
579+
# Its possible that the user may be trying to pass a MultiIndex here.
580+
# Attempt to convert columns to MultiIndex, and check length again.
581+
# This conversion should be safe to do, as the input expects an Index
582+
# and the colums are left unmodified throughout the rest of this function.
583+
columns = ensure_index(columns)
584+
if len(columns) != content_length:
585+
raise AssertionError(
586+
f"{len(columns)} columns passed, passed data had "
587+
f"{len(content)} columns"
588+
)
579589
raise AssertionError(
580590
f"{len(columns)} columns passed, passed data had "
581591
f"{len(content)} columns"

0 commit comments

Comments
 (0)