Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show all pandas dataframes in an IPython Notebook

How could I identify all the Pandas DataFrames created in my current notebook session?

Something like in SAS seeing all the members in the Work library would be ideal.

Thanks.

like image 688
Simon Avatar asked Jan 22 '16 15:01

Simon


People also ask

How do I see all Dataframe in pandas?

Method 2: Using set_option() A function set_option() is provided by pandas to display all rows of the data frame. display. max_rows represents the maximum number of rows that pandas will display while displaying a data frame. The default value of max_rows is 10.

How do you show a Dataframe in Jupyter notebook?

You can visualize a pandas dataframe in Jupyter notebooks by using the display(<dataframe-name>) function. The display() function is supported only on PySpark kernels. The Qviz framework supports 1000 rows and 100 columns.

How do I print a Dataframe in Jupyter?

You can use the print() method to print the dataframe in a table format. You can convert the dataframe to String using the to_string() method and pass it to the print method which will print the dataframe.


1 Answers

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:

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

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']
like image 146
Mike Müller Avatar answered Sep 27 '22 17:09

Mike Müller