I have two huge tables as pandas
objects that can hardly fit into memory, and I need to combine them into a third one:
df = pd.melt(df, id_vars='index', value_vars=cell_ids,
var_name='cell_id', value_name='expr')
df_raw = pd.melt(df_raw, id_vars='index', value_vars=cell_ids,
var_name='cell_id', value_name='raw_expr')
df_combined = pd.merge(df, df_raw, on="index")
Is there a way to delete df
and df_raw
on the fly while creating df_combined
, so that I would not get out of memory error while doing merge
operation?
This is not duplicate because:
I need to release the memory on the fly. I can not just del on two dataframes because I will not be able to run merge. I can not do del after running merge because out of memory error would already occur. So, I need a way of creating merged table and destroying the input ones at the same time. I thought that maybe there are some packages, software to actually achieve that.