del statement does not delete an instance, it merely deletes a name.

When you do del i, you are deleting just the name i - but the instance is still bound to some other name, so it won't be Garbage-Collected.

If you want to release memory, your dataframes has to be Garbage-Collected, i.e. delete all references to them.

If you created your dateframes dynamically to list, then removing that list will trigger Garbage Collection.

>>> lst = [pd.DataFrame(), pd.DataFrame(), pd.DataFrame()]
>>> del lst     # memory is released

If you created some variables, you have to delete them all.

>>> a, b, c = pd.DataFrame(), pd.DataFrame(), pd.DataFrame()
>>> lst = [a, b, c]
>>> del a, b, c # dfs still in list
>>> del lst     # memory release now
Answer from pacholik on Stack Overflow
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.DataFrame.drop.html
pandas.DataFrame.drop — pandas 3.0.2 documentation
Drop a specific index combination from the MultiIndex DataFrame, i.e., drop the combination 'falcon' and 'weight', which deletes only the corresponding row
Discussions

Removing rows from pandas dataframe efficiently?
I have to use data from two pandas dataframes but I’m having trouble figuring out how to remove data efficiently from the datasets. The df_books dataframe contains roughly 300k entries which includes book details (isbn, title, and author), while the df_ratings dataframe contains 1.1 million ... More on forum.freecodecamp.org
🌐 forum.freecodecamp.org
0
0
July 27, 2021
[Pandas] Efficiently delete rows from dataframe
I do not use pandas that often, but instead of dropping values have you tried to select the values you want to keep df = df[np.asarray(df.X != x) & np.asarray(df.Y != y) & np.asarray(df.Z != Z)] Notice that instead of == use != More on reddit.com
🌐 r/learnpython
2
2
April 21, 2015
How to release the memory of dataframe ?
Not sure if this will work better, but you could try: data = (pd.read_csv(file, usecols=['item id']) for file in folder) df = pd.concat(data, ignore_index=True) More on reddit.com
🌐 r/learnpython
6
9
July 19, 2021
r - How do I delete all pandas dataframe created by my python code - Stack Overflow
I'm using python 3.x.I would like to delete all pandas dataframe created by my python code. More on stackoverflow.com
🌐 stackoverflow.com
🌐
GeeksforGeeks
geeksforgeeks.org › python › memory-leak-using-pandas-dataframe
Memory leak using Pandas DataFrame - GeeksforGeeks
July 23, 2025 - You can use the del keyword in Python to delete a DataFrame object and free up the memory used by it. Loading only the data you need into your DataFrame: To avoid memory leaks, you should only load the data that you actually need into your ...
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.DataFrame.dropna.html
pandas.DataFrame.dropna — pandas 3.0.1 documentation
DataFrame.dropna(*, axis=0, how=<no_default>, thresh=<no_default>, subset=None, inplace=False, ignore_index=False)[source]#
🌐
freeCodeCamp
forum.freecodecamp.org › python
Removing rows from pandas dataframe efficiently? - Python - The freeCodeCamp Forum
July 27, 2021 - I have to use data from two pandas dataframes but I’m having trouble figuring out how to remove data efficiently from the datasets. The df_books dataframe contains roughly 300k entries which includes book details (isbn, …
🌐
Shane Lynn
shanelynn.ie › home › delete rows & columns in dataframes quickly using pandas drop
Delete Rows & Columns in DataFrames using Pandas Drop
December 17, 2021 - Learn how to drop or delete rows & columns from Python Pandas DataFrames using "pandas drop". Delete rows and columns by number, index, or by boolean values.
Find elsewhere
🌐
Reddit
reddit.com › r/learnpython › [pandas] efficiently delete rows from dataframe
r/learnpython on Reddit: [Pandas] Efficiently delete rows from dataframe
April 21, 2015 -

I have a dataframe containing around 2M rows and 6 columns. Based on 3 of those columns I want to delete certain rows. ATM my code looks like this:

df = df.drop( df[ (df.X == x) & (df.Y==y)  & (df.Z==Z)].index )

Unsurprisingly this isn't really fast, however, I couldn't find a way to do it faster.

PS: It's not that it takes ages, just 1 or 2 seconds, but I have to do it 30-40 times each run, so it adds up.

🌐
Sentry
sentry.io › sentry answers › python › delete a column from a dataframe in python pandas
Delete a column from a DataFrame in Python Pandas | Sentry
June 15, 2023 - This code will print the products DataFrame with three columns and then with two columns. We’ve used the following arguments in our drop method call: 'sale_price' is the name of the column to remove. We could also provide a column index (e.g. 2) or a list of indices or names to delete multiple columns.
🌐
Saturn Cloud
saturncloud.io › blog › how-to-release-memory-used-by-a-pandas-dataframe
How to Release Memory Used by a Pandas DataFrame | Saturn Cloud Blog
December 7, 2023 - One simple way to release memory used by a Pandas DataFrame is to use the del statement to delete the DataFrame object.
🌐
Reddit
reddit.com › r/learnpython › how to release the memory of dataframe ?
r/learnpython on Reddit: How to release the memory of dataframe ?
July 19, 2021 -

I have several big csv file. I want to extract the column "item id" in each on them.

And combine all of them and return a unique one.

My code is as follow:

    for csv_file in folder:
        df = pd.read_csv(csv_file)
        list_df.append(df['item id'])

    df_all_itemNo = pd.concat(list_df, ignore_index=True)
    df_all_itemNo = df_all_itemNo.drop_duplicates()

It is working when there is only a few csv file. The problem is when several big csv is read, all of my computer memory is used up.

From the memory usage graph, I see that the memory was keep on increasing. It never release back when every time

df = pd.read_csv(csv_file) is executed. The old df was stuck in memory.

Is there any solutions ?

🌐
W3Schools
w3schools.com › python › pandas › ref_df_drop.asp
Pandas DataFrame drop() Method
A DataFrame with the result, or None if the inplace parameter is set to True.
🌐
MLJAR
mljar.com › docs › pandas-delete-column
Delete Column in Pandas DataFrame
Use `drop()` function from Pandas package to delete column in DataFrame. You can drop single column or multiple columns at once. The drop operation is performed inplace.
🌐
GeeksforGeeks
geeksforgeeks.org › python › how-to-drop-one-or-multiple-columns-in-pandas-dataframe
How to Drop One or Multiple Columns in Pandas DataFrame - GeeksforGeeks
import pandas as pd df = pd.DataFrame({ 'A': [1, 2, None, 4], 'B': [None, None, None, 4], 'C': [1, 2, 3, 4] }) threshold = len(df) * 0.5 df = df.dropna(thresh=threshold, axis=1) print(df) Output · A C 0 1.0 1 1 2.0 2 2 NaN 3 3 4.0 4 · Explanation: len(df) * 0.5: sets 50% as the minimum non-null count required to keep a column. dropna(thresh=threshold, axis=1): removes columns with more than 50% missing data. Pandas Tutorial · Python | Delete rows/columns from DataFrame using Pandas.drop() Comment ·
Published   November 1, 2025
🌐
Vultr Docs
docs.vultr.com › python › third-party › pandas › drop
Python Pandas drop() - Remove Data Entries | Vultr Docs
December 30, 2024 - Drop rows based on a condition applied to the DataFrame. Use boolean indexing to specify the condition and drop() to remove the rows. ... This removes rows where 'Age' is 30 or less. It then attempts to drop rows labeled 'Peter' and 'Linda' directly, but notice a mistake: the correct index or labels are needed for successful deletion.
🌐
Edlitera
edlitera.com › blog › posts › pandas-add-rename-remove-columns
Intro to Pandas: How to Add, Rename, and Remove Columns in Pandas | Edlitera
November 15, 2022 - To make sure your DataFrame contains only the data that you want use in your project, you can add columns and remove columns from a DataFrame.
🌐
Thinking Neuron
thinkingneuron.com › home › how to delete variables from a pandas data frame
How to delete variables from a pandas data frame - Thinking Neuron
September 21, 2020 - If you need to delete some variables from the pandas dataframe, you can use the drop() function.