Skip to content

Commit b381327

Browse files
committed
DEPR: remove unordered types depreceation usage in core/index.py
1 parent 8016a7f commit b381327

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

pandas/core/index.py

+11-11
Original file line numberDiff line numberDiff line change
@@ -164,18 +164,18 @@ def __new__(cls, data=None, dtype=None, copy=False, name=None, fastpath=False,
164164
elif data is None or np.isscalar(data):
165165
cls._scalar_data_error(data)
166166
else:
167-
if tupleize_cols and isinstance(data, list) and data:
167+
if tupleize_cols and isinstance(data, list) and data and isinstance(data[0], tuple):
168168
try:
169-
sorted(data)
170-
has_mixed_types = False
171-
except (TypeError, UnicodeDecodeError):
172-
has_mixed_types = True # python3 only
173-
if isinstance(data[0], tuple) and not has_mixed_types:
174-
try:
175-
return MultiIndex.from_tuples(
176-
data, names=name or kwargs.get('names'))
177-
except (TypeError, KeyError):
178-
pass # python2 - MultiIndex fails on mixed types
169+
170+
# must be orderable in py3
171+
if compat.PY3:
172+
sorted(data)
173+
return MultiIndex.from_tuples(
174+
data, names=name or kwargs.get('names'))
175+
except (TypeError, KeyError):
176+
# python2 - MultiIndex fails on mixed types
177+
pass
178+
179179
# other iterable of some kind
180180
subarr = com._asarray_tuplesafe(data, dtype=object)
181181

0 commit comments

Comments
 (0)