Skip to content

MultiIndex.from_tuples returns an Index when all tuples are length 1 #17178

Closed
@TomAugspurger

Description

@TomAugspurger
In [1]: import pandas as pd
In [2]: pd.MultiIndex.from_tuples([('a',), ('b',)])
Out[2]: Index(['a', 'b'], dtype='object')

This should return a MultiIndex I think, like

Out[5]:
MultiIndex(levels=[['a', 'b']],
           labels=[[0, 1]])

Well, pd.MultiIndex([['a', 'b']], [[0, 1]]) returns the same thing as from_tuples (an index) so maybe this is intentional.

Trying to figure out if this is intentional or not (this came up in my categorical dtype refactor).

Metadata

Metadata

Assignees

No one assigned

    Labels

    IndexingRelated to indexing on series/frames, not to indexes themselvesMultiIndex

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions