Skip to content

IPython console plugin

Damien Farrell edited this page Jan 18, 2016 · 5 revisions

This plugin uses the IPython library to provide an embedded console in DataExplore. It is not a feature of the pandastable widget.

##Requirements

Requires that ipython is present. This is not a default dependency so the plugin won't appear if you haven't installed ipython. With the windows binary ipython is provided. To install:

pip3 install ipython

Usage

Open the plugin from the plugin menu. A console frame will appear below the table. Here you can call any Python commands and some shell commands provided in ipython. The table dataframe can be manipulated using python code and then redrawn to update the table.

The current table is accessed using the variable name 'table'. The current table data structure (the pandas DataFrame) is initially assigned to the variable 'df' for convenience. You will have to assign the variable table.model.df to alter the table frame. pandas and numpy are imported as pd and np. pandastable is imported as pt.

##Examples

Transpose the current table and update:

table.model.df = df.T
table.redraw()

Join the main and child table together:

df1 = table.model.df 
df2 = table.child.model.df
table.model.df = pd.concat([df1,df2])
table.redraw()

Create a table model from a dataframe and update the current table with it:

df = pd.DataFrame(pd.Series(np.arange(20),name='x'))
model = pt.TableModel(df)
table.updateModel(model) #redraws table also

##References

https://ipython.org/ipython-doc/3/interactive/tutorial.html