'Save data with locally defined objects: df.to_picke or %store won't work

I use to_pickle / read_pickle a lot to quickly backup my dataframes while I'm manipulating them. The problem is that some of the columns have objects of a class that I defined myself in a module that I'm using, so I'm getting

AttributeError: Can't pickle local object 'get_Rc.<locals>.Rc'

where Rc is of a class that I defined myself. Is there any other way I can dump my dataframes and re-read them?
The %store magic command throws the exact same error.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source