While turning a DEAP's Logbook (essentially, a list of Dictionaries) with around 10 MM entries into a Dataframe for further processing, I got a message about RAM overflow in Google Colab.
I'm using the DEAP package for some experiments, as my machine is slow and old I've been helping my self with the Colab service from Google. The result of the simulation is a DEAP's Logbook, this is a list of dictionaries. Each dictionary is a summary of important values of a screenshot of the simulation. I've been turning this list of dictionaries into Dataframes for analysis, but for the biggest simulations the process crashes due to it exceeding the allotted RAM.
The dictionaries store this kind of values:
logbook[-1]
{'avg': 16.72180244532359,
'b_ratio': 5,
'best': 0.006420736818512296,
'births': 80160,
'cx_pb': 0.9,
'exp': 128,
'k_par': 6,
'k_sur': 6,
'med': 2.6377157552245727,
'mut_pb': 0.9,
'mut_sig': 7.5,
'pop': 160,
'rep': 40,
'seed': 112,
'std': 20.059567935625164,
'worst': 55.23488779660829}
And the logbooks that I'm interested in storing as pandas dataframes have between 10MM and 12MM. Later, I'll reduce that count to around a fifth.
After pickling and unpickling the logbook I see that I'm using around 7.7GB from the allotted 12.7GB.
I've tried:
from itertools import chain
fitness_res = pd.DataFrame(list(chain.from_iterable(logbook)))
and
pop_records = [record for record in logbook]
fitness_res = pd.DataFrame(pop_records)
without success.
The error I got is:
Your session crashed after using all available RAM. View runtime logs
I expect to have a dataframe with all the data in the DEAP's Logbook.