I have lengthy computations which I repeat many times. Therefore, I would like to use memoization (packages such as jug and joblib), in concert with Pandas. The problem is whether the package would memoize well Pandas DataFrames as method arguments.
Has anyone tried it? Is there any other recommended package/way to do this?
Author of jug here: jug works fine. I just tried the following and it works:
It is not as efficient as it could be as it just uses
pickle
internally for theDataFrame
(although it compresses it on the fly, so it is not horrible in terms of memory use; just slower than it could be).I would be open to a change which saves these as a special case as jug currently does for numpy arrays: https://github.com/luispedro/jug/blob/master/jug/backends/file_store.py#L102
I use this basic memoization decorator,
memoized
. http://wiki.python.org/moin/PythonDecoratorLibrary#MemoizeDataFrames are hashable, so it should work fine. Here's an example.
Looks good to me.