Skip to content

Use DataExplore from within Python

Damien Farrell edited this page Mar 2, 2017 · 3 revisions

For users who work with DataFrames inside the Python interpreter it may be useful to be able to view them in DataExplore directly. This can be done quite easily by creating an instance of the application and passing your dataframe into it.

This can only be done with IPython without blocking console access. Simply launch ipython and then type %gui tk. Note that changing the dataframe in the application will alter it if loaded as shown below so you might want to make a copy of it first.

Usage

%gui tk #ipython magic
from pandastable.app import DataExplore
#create the application window
app = DataExplore()

#load a dataframe called 'df', you will be prompted for the new sheet name
app.load_dataframe(df)
#load a dataframe called 'df' into a sheet called 'new'
app.load_dataframe(df, 'new')

#load a dataset stored in the 'datasets' folder
app.getData('iris.mpk')

#load a dataframe stored in a msgpack file
app.load_msgpack('file.mpk')

#save your current work as a dataexplore project file
app.saveProject('mydata.dexpl')

#load a project
app.loadProject('mydata.dexpl')

#get the current table dataframe from the table model df attribute
t = app.getCurrentTable() #or t = app.sheets[sheetname]
df = t.model.df