Skip to content

BUG: set_index doesn't work with MI. #5358

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
jtratner opened this issue Oct 28, 2013 · 1 comment
Closed

BUG: set_index doesn't work with MI. #5358

jtratner opened this issue Oct 28, 2013 · 1 comment

Comments

@jtratner
Copy link
Contributor

Changes it to tuples instead (so it's probably just converting to list or going to values somewhere)

In [9]: df = DataFrame(list(zip(range(3), range(3), range(3), range(3))))

In [10]: ind = MultiIndex.from_arrays([['x', 'y', 'z'], [4, 4, 5]], names=['ind1', 'ind2'])

In [11]: df.set_index(ind)
Out[11]:
        0  1  2  3
(x, 4)  0  0  0  0
(y, 4)  1  1  1  1
(z, 5)  2  2  2  2
In [12]: df.reindex(ind) # works
Out[12]:
            0   1   2   3
ind1 ind2
x    4    NaN NaN NaN NaN
y    4    NaN NaN NaN NaN
z    5    NaN NaN NaN NaN
In [13]: df2 = df.copy()

In [14]: df2.index = ind # works too

In [15]: df2
Out[15]:
           0  1  2  3
ind1 ind2
x    4     0  0  0  0
y    4     1  1  1  1
z    5     2  2  2  2
@ghost ghost assigned jtratner Oct 28, 2013
@jreback
Copy link
Contributor

jreback commented Apr 4, 2014

was fixed by #6459

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants