Show all pandas dataframes in IPython Notebook

How can I identify all Pandas DataFrames created in the current recording session?

Something like SAS, seeing that all members in the working library will be perfect.

Thanks.

+6
source share
2 answers

Decision

%who DataFrame 

Explanation

All objects

... seeing that all the members in the working library will be perfect.

 In [1]: a = 10 b = 'abs' c = [1, 2, 3] 

%who shows all the names used:

 In [2]: %who abc 

Convenient as a list:

 In [3]: %who_ls Out[3]: ['a', 'b', 'c'] 

Or as a table with data types:

 In [4]: %whos Variable Type Data/Info ---------------------------- a int 10 b str abs c list n=3 

Filter for DataFrames

 In [5]: import pandas as pd df1 = pd.DataFrame({'a': [100, 200, 300]}) df2 = pd.DataFrame({'b': [100, 200, 300]}) In [6]: %whos DataFrame Variable Type Data/Info --------------------------------- df1 DataFrame a\n0 100\n1 200\n2 300 df2 DataFrame b\n0 100\n1 200\n2 300 In [7]: %who DataFrame df1 df2 In [8]: %who_ls DataFrame Out[8]: ['df1', 'df2'] 
+10
source

If you mean memory, try something like:

 for i in dir(): if type(globals()[i]) == pandas.DataFrame: print(i) 

or some such.

+3
source

All Articles