[Python] How do I release memory used by a pandas dataframe?

Discussão em 'Python' iniciado por Stack, Março 3, 2025.

  1. Stack

    Stack Membro Participativo

    I have a really large csv file that I opened in pandas as follows....

    import pandas
    df = pandas.read_csv('large_txt_file.txt')


    Once I do this my memory usage increases by 2GB, which is expected because this file contains millions of rows. My problem comes when I need to release this memory. I ran....

    del df


    However, my memory usage did not drop. Is this the wrong approach to release memory used by a pandas data frame? If it is, what is the proper way?

    Continue reading...

Compartilhe esta Página