-
- Notifications
You must be signed in to change notification settings - Fork 19.4k
Description
T = tuple(tuple(range(k)) for k in range(1, 8)) #Note: min(map(len, T)) == 1 and max(map(len, T)) == 7 bad = pd.MultiIndex.from_tuples(T) bad.nlevels # == 1 ??? good = pd.MultiIndex.from_tuples(list(T)) good.nlevels # == 7Problem description
The docstring leaves some ambiguity as to whether a tuple or list can be passed in. It does say a list of tuples at the top, but in the argument specification, it hints that tuples can be a list/sequence of tuple-likes. A tuple of tuples is a sequence of tuple-likes. I find it strange that my tuple of tuples was truncated to a single level MultiIndex, while my list of tuples was not.
Changing https://github.com/groutr/pandas/blob/master/pandas/indexes/multi.py#L983
to call itertools.zip_longest would fix the truncation issue.
I also don't understand why sometimes the arrays are transposed and every other case we don't transpose.
https://github.com/groutr/pandas/blob/master/pandas/indexes/multi.py#L980-L983
Expected Output
I would expect lists and tuples and other sequences of tuple-likes (sets, for example) to be treated the same. Do lists have a special meaning here?
This is in the latest master (588e29d) and pandas 0.19.1.
I'd be happy to submit a PR if this is unintended behavior