在Jupyter Notebook上,如何在执行所有单元格后如何使用代码释放运行中的内存,而无需手动单击重新启动按钮

时间:2020-05-29 17:03:28

标签: python jupyter-notebook

是否有代码可以清除笔记本的内存?我正在使用for循环将数据帧保存到csv。但是,当循环增加时,运行的内存也会增加。溢出时,笔记本的内核无法工作。谁能告诉我内存增加的原因?我的想法是在不关闭笔记本计算机的情况下清除jupyter内存,这样可以避免内存不足的问题。我想听听其他更好的建议。代码如下。

num = 2062
for date in tqdm(trade_day[num:num+70]):
    # data is a dataframe, when saving it to a csv file, the size of file is about 3 to 4 MB
    data = alpha(enddate=date, index=stock_list, fq='pre')
    data.to_csv(str(date)+'.csv')

0 个答案:

没有答案
相关问题