gpt4 book ai didi

python - pandas 不释放内存?

转载 作者:太空宇宙 更新时间:2023-11-04 03:31:50 25 4
gpt4 key购买 nike

我确实有一个包含 40000 行和三列的数据框。如果我在 ipython 笔记本的不同单元格中重复执行 df.set_index('my_ind').head(),RAM 将被填充但不会被释放:

enter image description here

我以为这个函数只是返回数据框的 View 。 gc.collect() 没有释放任何 RAM。知道为什么 pandas 不释放 RAM 吗?

最佳答案

set_index() 中使用 inplace=True

如果没有 inplace=True 参数,您每次都会创建一个新的数据框。

关于python - pandas 不释放内存?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30849226/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com