Pandas GroupBy memory deallocation

前端 未结 2 918
孤独总比滥情好
孤独总比滥情好 2021-02-07 04:28

Problem

I noticed that memory allocated while iterating through a Pandas GroupBy object is not deallocated after iteration. I use resource.getrusage(resource.RUSA

相关标签:
2条回答
  • 2021-02-07 04:49

    Why is memory for DataFrames resulting from iteration through the groupby not deallocated after iteration is completed?

    Nowhere in your code you del object gb, which means at the end it's still there. One thing is to have an iterator reach the end of its cycle, then I would expect it to die automagically, but the object that gave rise to the iterator persists, in case you need to do something else (iterate again, aggregate, etc).

    0 讨论(0)
  • 2021-02-07 04:53

    Memory Weirdness

    This is very interesting! You do not need del idx, x. Only using gc.collect() worked to keep memory constant for me. This is much cleaner that having the del statements inside the loop.

    0 讨论(0)
提交回复
热议问题