Run a script quickly from second time onward

Question:

I have a python script that takes a lot of time to complete.
The line that takes most of the time is:

ndf['embeddings'] = ndf['embeddings'].apply(ast.literal_eval) 

Is there any way to pickle the results so that I will have to wait only for the first time?

Asked By: shantanuo

||

Answers:

sure

ndf.to_pickle("mydf.pkl")

should do just that

you can then load it with pandas.read_pickle("mydf.pkl")

Answered By: Joran Beasley
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.