如何列出,在我的jupyter笔记本IDE上显示创建的对象



我创建了很多对象名称,超过500个对象。

好吧,我的问题是:我如何查看创建的对象,或者如何清除空间,这样我就可以在目录上节省一些空间。

它根本不会影响我的存储?

1(为了检查全局创建的对象,我建议使用变量检查器扩展。有关安装,请参阅文档。

2( 为了清理全局变量,您可以运行:

  • 带提示的%reset
  • %reset -f无提示
  • %reset_selective <regular_expression>以清除与正则表达式匹配的选定变量

有关%重置和%重置_选择性的更多信息

扩展Mike的答案:

## create some variables/objects
a = 5
b = 10
import numpy as np
import pandas as pd
df = pd.DataFrame(np.random.randint(1,100, size=(4,2)), columns=list('AB'))
print(a,b,'n', df)
## check
%who
# >>> a b df np pd

#%%% Delete all
## clear with prompt
%reset
## clear without confirmation prompt
%reset -f
# check
%who

#%%% Delete specific
#%%%%  %reset_selective <regular_expression>
## clear with prompt
%reset_selective df
## clear without prompt
%reset_selective -f df
# multiple
%reset_selective -f [a,b]
# %reset_selective -f a,b  << doesn't work
## check
%who

#%%%% del
# clears without prompt
del a
## multiple
del [a,b]
# or
del a,b
## check
%who

最新更新