Skip to content

Commit

Permalink
Prevent 3D-ndarray for nested tuple labels (#24687)
Browse files Browse the repository at this point in the history
  • Loading branch information
shanekimble committed Jan 11, 2019
1 parent fdc4db2 commit f8fa18d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pandas/core/indexes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -5282,6 +5282,12 @@ def ensure_index(index_like, copy=False):
if len(converted) > 0 and all_arrays:
from .multi import MultiIndex
return MultiIndex.from_arrays(converted)
elif converted.size > 2:
# When nested tuples are incorrectly converted
# to > 2 dimensions (Extremely rare)
index_like = np.ndarray((1, 2), dtype=tuple)
index_like[0][0] = tuple(converted[0][0])
index_like[0][1] = tuple(converted[0][1])
else:
index_like = converted
else:
Expand Down

0 comments on commit f8fa18d

Please sign in to comment.