Closed
Description
I'm in a bit of a pickle here. If I try to save and read back a multi-indexed dataframe, I get this error (and in some situations, can't reproduce when, I get a TypeError: Required argument 'shape' (pos 1) not found
error).
The gist with the full traceback is here.
In [3]: import numpy as np
In [4]: import pandas as pd
In [5]: np.random.seed(10)
In [6]: a = np.random.randint(0, 20, (6, 5))
In [7]: df = pd.DataFrame(a).set_index([2,3,4])
In [8]: df
Out[8]:
0 1
2 3 4
15 0 17 9 4
8 9 0 16 17
4 19 16 10 8
11 11 1 4 15
14 17 19 8 4
13 19 13 13 5
In [9]: df.to_pickle('~/Desktop/dummy.df')
In [10]: df2 = pd.read_pickle('~/Desktop/dummy.df')
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
...
TypeError: 'FrozenList' does not support mutable operations.
When I reset_index
it saves fine. I'm on Mac OSX, numpy 1.7, pandas 0.12.0-361-g53eec08.
In the meantime, if there's no quick fix, anyone know another way to save multi-indexes to file? csv doesn't look like it can preserve them. I could do something like appending _index
to the columns and un-rename them after reading but would prefer something less hacky.