wesm/pandas — Issue #262: Index names lost when calling sort_index
Author: wesm
Created: 2011-10-20 15:11:40+00:00
State: open
Labels: Bug

```
MultiIndex names get lost in the returned dataframe after sort_index is used.
Here is an example:

In [1]: import pandas

In [2]: pandas.__version__
Out[2]: '0.4.3'

In [3]: index = pandas.MultiIndex.from_tuples([('x','y','z'), ('a','b','c'), ('p','q','r')], names=['one','two','three'])

In [4]: df = pandas.DataFrame(randn(3, 5), index=index)

In [5]: df
Out[5]:
0 1 2 3 4
x y z -1.098 -0.3314 -0.5526 0.3791 1.12
a b c 1.141 0.3309 -0.6509 -0.561 -1.086
p q r 0.3399 -0.3135 1.677 0.533 0.1158

In [6]: df.index.names
Out[6]: ['one', 'two', 'three']

In [7]: dfs = df.sort_index()

In [8]: dfs
Out[8]:
0 1 2 3 4
a b c 1.141 0.3309 -0.6509 -0.561 -1.086
p q r 0.3399 -0.3135 1.677 0.533 0.1158
x y z -1.098 -0.3314 -0.5526 0.3791 1.12

In [9]: dfs.index.names
Out[9]: [None, None, None]
```