Serialize a dictionary containing pandas data-frames (Python)

dataframe, dictionary, pandas, python, serialization

Solution

Use pickle.dump(s) and pickle.load(s). It actually works. Pandas DataFrames also have their own method df.save("filename") that you can use to serialize a single DataFrame...

Problem

I have a dict containing several pandas Dataframe (identified by keys) , any suggestion to effectively serialize (and cleanly load) it . Here is the structure (a pprint display output ). Each of dict['method_x_']['meas_x_'] is a pandas Dataframe. The goal is to save the dataframes for a further plotting with some specific plotting options. {'method1': {'meas1': ``` config1 config2 0 0.193647 0.204673 1 0.251833 0.284560 2 0.227573 0.220327, ``` ``` 'meas2': ``` ``` config1 config2 0 0.172787 0.147287 1 0.061560 0.094000 2 0.045133 0.034760, ``` 'method2': { 'meas1': ``` congif1 config2 0 0.193647 0.204673 1 0.251833 0.284560 2 0.227573 0.220327, ``` 'meas2': ``` config1 config2 0 0.172787 0.147287 1 0.061560 0.094000 2 0.045133 0.034760}} ```

Original source

Related problems