I just want to see if anybody can see an error in what I'm doing before I go and open an issue...
Minimal example - first create a multi-index dataframe:
miindex = pd.MultiIndex.from_product([["x","y"], ["10","20"]],names=['row-foo', 'row-bar'])
micol = pd.MultiIndex.from_product([['a','b','c'], ["1","2"]],names=['col-foo', 'col-bar'])
df = pd.DataFrame(index=miindex, columns=micol).sortlevel().sortlevel(axis=1)
df = df.fillna(value=3.14)
df
This gives us a nice test multi-index with column and row level names:
Now if I make a sparse matrix out of that and show it, the column level names are gone:
ds = df.to_sparse()
ds
And if I convert the sparse version back to dense those level names are still gone:
tf = ds.to_dense()
tf
Now I AM aware that displaying the sparse version calls to_dense() but the loss appears to be happening at the conversion to sparse. I'm exploring moving to sparse to reduce memory usage for a code base and my attempts to access the levels within the sparse dataframe generate "KeyError: 'Level not found'"
Anyone know how to preserve column level names in a pandas sparse dataframe?
(Tests shown on pandas 0.17.0, also observed on 0.16.2)


