Jupyter_contrib_nbextensions: A variable explorer for notebook? (like MATLAB's Workspace)

Created on 7 Jun 2016  路  16Comments  路  Source: ipython-contrib/jupyter_contrib_nbextensions

I want to know if there is anything like MATLAB's Workspace? (or Spyder's Variable Explorer). So we can easily copy the values out. Something look like this:

enter image description here


I ask it here (https://github.com/jupyter/notebook/issues/1516), Carreau gives a very good example. In short, you can get the variables by this:

variables = %who_ls
for v in variables:
    print v, type(eval(v)).__name__, str(eval(v))

Another thing worth considering is spyderlib.plugins.variableexplorer from Spyder. This could be seen at http://stackoverflow.com/questions/2960864/how-can-i-save-all-the-variables-in-the-current-python-session

enhancement

Most helpful comment

How about the Variable Inspector extension?

All 16 comments

@janschulz Never thought of Rodeo, I thought it was about desktop version.
Never heard of jupyterlab, is it this? https://github.com/jupyter/jupyterlab

rodeo isn't a notebook app, but also uses the kernel infrastructure and has a browser UI (Rodeo (and RStudio on which rodeo is based) are basically a browser window).

RE jupyterlab: I've heard some stuff about it (there was a survey which (also) said "we need more IDE feature in the Notebook UI" and I think jupyterlab is building infrastructure for suchthings) but I've actually no clue what the overall vision is for that thing...

The original answer in the notebook repo linked to https://github.com/ipython/ipywidgets/blob/master/docs/source/examples/Variable%20Inspector.ipynb -> doesn't look so complicated :-)

@janschulz Yes, that widget is pretty amazing and simple. The problem is that how to make it "copy and pastable", i.e. have table display UI for array and matrix.

Addtionally, I personally want a Ruby on Rails-like framework for Jupyter Notebook, in which have pre-load common use nbextensions, libraries and good file organizations. It can help people get to know useful features, extentions at the beginning, saving people tons of time for configuration.

to be cross-language-compatible we need a protocol extension AFAICS:

  1. a request to the kernel to return the names and types of variables.
  2. a request to the kernel to open an interactive editor for a variable or at least display it (i.e. the kernel can reply with a open-pager message or create a widget able to edit the variable)

@cqcn1991 to get what you want right now, you can do something like

from IPython.core.page import page
from IPython.core.formatters import format_display_data

page(format_display_data(thing, ['text/plain', 'text/html']))

(the second argument to format_display_data is only for performance since the pager can鈥檛 handle more mimetypes anyway)

@flying-sheep what is thing in page(format_display_data(thing, ['text/plain', 'text/html']))?

the variable you want to display. to get it there鈥檚 a bit more work involved:

  1. you have to set up JS event listeners for the cells that send a comm request to the kernel
  2. you have to set up event listeners in python that react to that comm request and do thing = ipython.kernel.shell.user_ns[varname]

Would be a great feature!

How about the Variable Inspector extension?

Does the variable inspector work in Jupyterlab?

Does the variable inspector work in Jupyterlab?

No, jupyterlab uses a different (and so far still constantly-changing) javascript model, so I know of no extensions that work there yet

A varInspector is planned in the future in JupyterLab, see the roadmap.

Also, it is planned in the notebook development roadmap for Jupyter v 5+ to port/bridge popular nbextension "we will continue to work on porting nbextensions to JupyterLab and building the bridge layers." and "At least some important, popular extensions are ported / bridged to Jupyter Lab". Of course we will be happy to port or help, but for now the interface seems not quite stable and/or I don't find easy keys.

How about the Variable Inspector extension?

This works for simple variables, but a better presentation (i.e. like that of in Spyder) of dataframes/matrices/vectors is much appreciated.

Alternatively, I also tried running jupyter notebooks inside spyder, this did not work well.

@ biocyberman, i think i'm exactly looking for the same like you. Did you find a better variable explorer than the variable inspector in Jupyter?

Was this page helpful?
0 / 5 - 0 ratings