I am running a long ETL pipeline in pandas. I have to create different pandas dataframes and I want to release memory for some of the dataframes.
I have been reading how to release memory and I saw that runing this command doesn't release the memory:
del dataframe
Following this link: How to delete multiple pandas (python) dataframes from memory to save RAM?, one of the answer say that del statement does not delete an instance, it merely deletes a name.
In the answer they say about put the dataframe in a list and then del the list:
lst = [pd.DataFrame(), pd.DataFrame(), pd.DataFrame()]
del lst
If I only want to release one dataframe I need to put it in a list and then delete a list like this:
lst = [pd.DataFrame()]
del lst
I have seen also this question: How do I release memory used by a pandas dataframe?
There are different answers like:
import gc
del df_1
gc.collect()
Or
just at the end of the dataframe use
df = ""
or there is a better way to achieve that?