1

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

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

或者

它不会影响我的存储吗?

4

2 回答 2

2

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

2)为了清理你可以运行的全局变量:

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

更多关于%reset%reset_selective

于 2020-05-02T08:02:04.737 回答
1

扩展迈克的回答

## 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
于 2021-01-10T05:26:54.593 回答