Skip to content

BUG: unique on an empty MI #20568

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jreback opened this issue Mar 31, 2018 · 2 comments
Closed

BUG: unique on an empty MI #20568

jreback opened this issue Mar 31, 2018 · 2 comments
Labels
Bug Indexing Related to indexing on series/frames, not to indexes themselves MultiIndex
Milestone

Comments

@jreback
Copy link
Contributor

jreback commented Mar 31, 2018

In [13]: pd.MultiIndex.from_arrays([[], []])
Out[13]: 
MultiIndex(levels=[[], []],
           labels=[[], []])

In [14]: pd.MultiIndex.from_arrays([[], []]).unique()
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-14-d5be3b23b8c3> in <module>()
----> 1 pd.MultiIndex.from_arrays([[], []]).unique()

~/pandas/pandas/core/indexes/multi.py in unique(self, level)
   1071 
   1072         if level is None:
-> 1073             return super(MultiIndex, self).unique()
   1074         else:
   1075             level = self._get_level_number(level)

~/pandas/pandas/core/indexes/base.py in unique(self, level)
   4366             self._validate_index_level(level)
   4367         result = super(Index, self).unique()
-> 4368         return self._shallow_copy(result)
   4369 
   4370     def drop_duplicates(self, keep='first'):

~/pandas/pandas/core/indexes/multi.py in _shallow_copy(self, values, **kwargs)
    558             # discards freq
    559             kwargs.pop('freq', None)
--> 560             return MultiIndex.from_tuples(values, **kwargs)
    561         return self.view()
    562 

~/pandas/pandas/core/indexes/multi.py in from_tuples(cls, tuples, sortorder, names)
   1315             if names is None:
   1316                 msg = 'Cannot infer number of levels from empty list'
-> 1317                 raise TypeError(msg)
   1318             arrays = [[]] * len(names)
   1319         elif isinstance(tuples, (np.ndarray, Index)):

TypeError: Cannot infer number of levels from empty list

@jreback jreback added Bug Indexing Related to indexing on series/frames, not to indexes themselves MultiIndex Difficulty Intermediate labels Mar 31, 2018
@jreback jreback added this to the 0.23.0 milestone Mar 31, 2018
@jreback
Copy link
Contributor Author

jreback commented Mar 31, 2018

xref #20544 (comment)

cc @WillAyd
@toobaz

@toobaz
Copy link
Member

toobaz commented Mar 31, 2018

Duplicate of #20308

@toobaz toobaz marked this as a duplicate of #20308 Mar 31, 2018
@toobaz toobaz closed this as completed Mar 31, 2018
toobaz added a commit to toobaz/pandas that referenced this issue Mar 31, 2018
toobaz added a commit to toobaz/pandas that referenced this issue Mar 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Indexing Related to indexing on series/frames, not to indexes themselves MultiIndex
Projects
None yet
Development

No branches or pull requests

2 participants