Skip to content
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

ENH: change Index unique to return an Index/MultiIndex (rather than ndarray) #4126

Closed
jreback opened this issue Jul 4, 2013 · 0 comments
Closed
Labels
Duplicate Report Duplicate issue or pull request Enhancement Ideas Long-Term Enhancement Discussions Indexing Related to indexing on series/frames, not to indexes themselves MultiIndex

Comments

@jreback
Copy link
Contributor

jreback commented Jul 4, 2013

Change unique to return an Index/MultiIndex as needed (rather than an ndarray)

In [81]: tuples = [(0, 100, 1000),(0, 100, 1001),(0, 100, 1002), (1, 101, 1001)]

In [82]: index_3levels=pd.MultiIndex.from_tuples(tuples,names=["l1","l2","l3"])

In [83]: index_3levels
Out[83]: 
MultiIndex
[(0, 100, 1000), (0, 100, 1001), (0, 100, 1002), (1, 101, 1001)]

In [84]: index_3levels.droplevel('l3')
Out[84]: 
MultiIndex
[(0, 100), (0, 100), (0, 100), (1, 101)]

This becomes more intuitive (or maybe add uniquify keyword to droplevel?

In [85]: MultiIndex.from_tuples(index_3levels.droplevel('l3').unique())
Out[85]: 
MultiIndex
[(0, 100), (1, 101)]
@jreback jreback modified the milestones: 0.15.0, 0.14.0 Feb 15, 2014
@jreback jreback modified the milestones: 0.16.0, Next Major Release Mar 1, 2015
@jreback jreback closed this as completed Jun 8, 2016
@jorisvandenbossche jorisvandenbossche modified the milestones: No action, Next Major Release Jun 8, 2016
@jorisvandenbossche jorisvandenbossche added the Duplicate Report Duplicate issue or pull request label Jun 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate Report Duplicate issue or pull request Enhancement Ideas Long-Term Enhancement Discussions Indexing Related to indexing on series/frames, not to indexes themselves MultiIndex
Projects
None yet
Development

No branches or pull requests

2 participants