Skip to content

Cannot represent empty MultiIndex #263

Closed
@asqui

Description

@asqui

An empty MultiIndex cannot be constructed:

In [120]: pa.MultiIndex([],[])
---------------------------------------------------------------------------
Exception                                 Traceback (most recent call last)
C:\Users\dfortunov\<ipython-input-120-ca5695a01949> in <module>()
----> 1 pa.MultiIndex([],[])

C:\VirtualEnvs\mss.dev\lib\site-packages\pandas-0.5.0.dev20111019_17461b7-py2.6-win32.egg\pandas\core\index.pyc in __new
__(cls, levels, labels, sortorder, names)
    833         assert(len(levels) == len(labels))
    834         if len(levels) == 0:
--> 835             raise Exception('Must pass non-zero number of levels/labels')
    836
    837         if len(levels) == 1:

Exception: Must pass non-zero number of levels/labels

This does not maintain parity with regular indices, where an empty index may be constructed:

In [119]: pa.Index([])
Out[119]: Index([], dtype=object)

And causes problems when doing set operations with MultiIndexes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions