简体   繁体   English

在IPython Notebook中显示所有pandas数据帧

[英]Show all pandas dataframes in an IPython Notebook

How could I identify all the Pandas DataFrames created in my current notebook session? 如何识别当前笔记本会话中创建的所有Pandas DataFrame?

Something like in SAS seeing all the members in the Work library would be ideal. 在SAS看到工作库中的所有成员都是理想的。

Thanks. 谢谢。

Solution

%who DataFrame

Explanation 说明

All objects 所有对象

... seeing all the members in the Work library would be ideal. ......看到工作库中的所有成员都是理想的。

In [1]:

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

%who shows all used names: %who显示所有使用的名称:

In [2]:
%who
a    b   c   

Conveniently as a list: 方便地作为列表:

In [3]:
%who_ls

Out[3]:
['a', 'b', 'c']

Or as table with data types: 或者作为数据类型的表:

In [4]:
%whos

Variable   Type    Data/Info
----------------------------
a          int     10
b          str     abs
c          list    n=3

Filter for DataFrames 过滤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']

If you mean memory try something like: 如果你的意思是记忆尝试类似:

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

or some such. 或者其他一些。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM