Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Viewing a table object in a new window #3692

Open
pdeffebach opened this issue Jan 20, 2018 · 23 comments
Open

Viewing a table object in a new window #3692

pdeffebach opened this issue Jan 20, 2018 · 23 comments

Comments

@pdeffebach
Copy link

pdeffebach commented Jan 20, 2018

In notebook mode, it is possible to right-click on a cell and select "Create new view for output". Is there any way to do this in the code itself? Something like

import pandas as pd
df  = pd.read_csv("file_path...")
new_view(df)

This would then open up a new tab for easier viewing of a very large table, and not clog up your notebook.

I apologize if this is already a feature, or is against the philosophy of the ipython notebook.

On second thought, would this only be able to be done as a console command? I can understand how this would make python notebooks not transportable at all.

@ellisonbg
Copy link
Contributor

I haver thought about adding some optional metadata that kernels could provide to indicate that output should be put either in a new main work area panel of even in the left sidebar. My only hesitancy on this is that it adds JupyterLab specific metadata to kernels, which wouldn't work with other frontends. However, if that metadata is optional, maybe it is ok?

@rgbkrk I would love your take on this?

One big usage case that I ran into is the progress bars that many libraries now have (such as keras). It would be nice to have them render in the left sidebar so those things don't clog up the document.

@rgbkrk
Copy link
Member

rgbkrk commented Jan 21, 2018

People have certainly asked for ways to dock outputs in a separate window in nteract. It's a doable thing, even there. For us it means we're making another window. I could imagine a metadata field or message type (I'd lean towards this more) that says to "dock" separately. Not sure what the semantics would be.

@ellisonbg
Copy link
Contributor

ellisonbg commented Jan 21, 2018 via email

@rahuldave
Copy link

rahuldave commented Mar 11, 2018

I'd love for this sort of access to be provided at the js level. This would make it possible for an extension to, say on the click of a button, use the sandbox extension to load a web site in the right hand side panel. Similarly a button could be provided in an enhanced dataframe output in the notebook view which opened the dataframe rstudio style in a separate panel (whats currently provided by the csv viewer panel)

(I do know you can add new view for output, but i's like to be eventually be able to do this by default. Here is a use case. I'd like to write a nbviewer style extension, in which clicking on a cell could bring up a discourse forum on the cell for discussion in a new sandbox view. Wood be cool for teaching)

@xappppp
Copy link

xappppp commented May 23, 2018

Maybe I'm wrong, but the link below seems to be a useful trick.
https://stackoverflow.com/questions/40554839/pop-out-expand-jupyter-cell-to-new-browser-window

@saulshanabrook
Copy link
Member

I could imagine a metadata field or message type (I'd lean towards this more) that says to "dock" separately.

@rgbkrk What about a custom mimetype that nests other mimetypes? I am just thinking about what's easiest to implement in kernel code.

@rgbkrk
Copy link
Member

rgbkrk commented May 23, 2018

@Carreau and I talked about this a while ago (some sort of container mimetype). What we ended up figuring out was that having display take variadic arguments made it really easy to display lots:

display(
  obj1,
  obj2
)

What I was saying about that metadata was something like this:

display(obj, metadata=dict(dock=True))

or simply:

display(obj, dock=True)

My thoughts on this are pretty old / stale though.

@BoPeng
Copy link
Contributor

BoPeng commented May 23, 2018

I think this is exactly the %preview magic of the SoS kernel for Jupyter where the preview of variable is sent to a side panel. The proposed solution for JupyterLab was a transient_display_data message and a matching UI.

@aldanor
Copy link

aldanor commented Jun 7, 2018

Just wanted to mention another somewhat typical usecase -- long-running tasks (e.g. machine learning / model fitting) generating a ton (thousands of lines) of intermediate output, inline, in real-time.

Something like a %preview magic would be absolutely cool to have, so the output is automatically routed to a new view. Would it have to be text (stdout/stderr) only, or rather anything that can be display()ed (e.g. dataframes or plots)?

@BoPeng
Copy link
Contributor

BoPeng commented Jun 7, 2018

Yes, the %preview magic can display tables (searchable and sortable) and figures. You can use it now with classic jupyter. Let us know if the kernel you are using is not supported by SoS yet.

@aldanor
Copy link

aldanor commented Jun 7, 2018

Yep, that's very close. Would be great to eventually have it working this way or another in a default jupyterlab installation, even if in a simplified form of some sort.

@gkvoelkl
Copy link

gkvoelkl commented Sep 16, 2018

Doing “create new view for output” with Python API? #4021
Will there be a solution?
Is there an Python API that can communicate with jupyterlab?
I wrote some nbextension. It is very difficult and not intuitive.
It would be great if there will be a pythonic way of writing extensions in jupyterlab.

@pdeffebach
Copy link
Author

Would the new DataBus feature in #5857 be helpful in making this feature easier to implement?

@saulshanabrook
Copy link
Member

Would the new DataBus feature in #5857 be helpful in making this feature easier to implement?

Possibly! We haven't settled yet what the UX experience should be for opening a dataset from a notebook.

@SylvainCorlay
Copy link
Member

It seems that the jupyterlab-sidecar package fills that purpose perfectly.

@gjoseph92
Copy link

@SylvainCorlay I disagree there. When JupyterLab natively provides a rich system for managing views, having a separate widget to duplicate that functionality isn't a good long-term solution.

For example, you can't drag a sidecar to another side. You can't drag it to split the view horizontally instead of vertically. You can't drag it to the tab bar to display in as its own full-size window. You can't navigate between sidecars with the standard keyboard shortcuts. It's a bit of an awkward workaround for a system that already provides this functionality well.

Allowing code to open new native views opens the door to creating much richer UIs within the JupyterLab ecosystem. (What I'm trying to do right now, and finding this a blocker.)

LMK if there's a way I can help out with moving this along.

@gkvoelkl
Copy link

gkvoelkl commented Jul 2, 2019

I tried sidecar. It is a great tool. But so far I understand, you can’t control the window with parameters.

What I need is an Python API that can communicate with Jupyterlab. It would be easier for Python programmer who are not so good in JavaScript.

@gjoseph92 I think it would be great if JupyterLab has a Python API to all UI stuff that’s already available. I do not know much about Jupyterlab. I did some Jupyter-widget. If i could help, I am in.

@ellisonbg
Copy link
Contributor

ellisonbg commented Jul 22, 2019 via email

@NumesSanguis
Copy link

NumesSanguis commented Nov 28, 2019

I want to add another perspective to this discussion: Cooperation between Data Scientists and other teams (Dashboard).

  • The problem that @ellisonbg Data Explorer solves is that of Notebook clutter by separating the data from the code and giving powerful tools for insights. This is very helpful for the Data Scientist (or related titles), but doesn't help when you want to communicate findings to Marketing / Consultancy / other people less fluent in programming.
  • Dashboards are very useful for the people scared at seeing code. In my case I want the output to be displayed in a separate window with dashboard items like sliders and buttons. In this way the non-programmer can play around with the data. How I would see this:
    • Single-Document Mode for Output View with tabs. Single-Document allows for the code to be hidden (already working), but to make it less cluttered, tabs would allow for mini-dashboards, instead of long-scrollable pages (which are annoying if you have elements that themselves are scrollable, like DataFrames)
    • Options on how to arrange the visual output. Maybe integration with Pyviz Panel?
    • Current issue: If Display() is called in two different cells, the output cannot be in the same Output View. This creates a unnatural workflow, in which all Display calls have to be grouped together at the end of a Notebook.

Implementation-wise I could imagine it be like one of these:

  • Add options to Display() (similar to @rgbkrk 's suggestion) like name="foo" (creates a new Output View if no view with "foo" exists, or adds output to existing "foo" Output View), and group="spam"(allows for side tabs in the output view, like sidecar)
  • Have Display() accept a View Description object and allow other libraries control how output should be displayed. E.g. Panel output. Somewhat more separation between backend and frontend.

I agree with @ellisonbg that backend and frontend should be separated as much as possible, but I would argue that Display() is already linked to frontend in terms that it generates instructions how content should be displayed.


Edit: This added functionality to Display could help other libraries, like Pyviz, to prevent bugs like this (output shown twice in Notebook, but not at all in Output View): holoviz/pyviz_comms#3

@Trezorro
Copy link

Trezorro commented Dec 16, 2019

Adding to the suggestions for inspecting views of pandas dataframes in a movable side window, I'm very much thinking about the RStudio plotting workflow and how beneficial that would be for data exploration in Jupyter Lab.

How might such functionality of plotting to a separate side window be implemented best?
Should it be added as an extra option for the %matplotlib magic? Or should plt.plot() accept some parameters referring to a specific output window (or slide, or tab) to be populated, similar to the suggestions made by @NumesSanguis for Display(obj)?

How useful it would be to be able to compare plots by dragging them around next to each other, perhaps even interacting with them %matplotlib notebook style, or flicking through consecutive plot 'slides' RStudio style. Anything that cuts out all the scrolling while drafting notebooks would be an improvement in my opinion.

@psychemedia
Copy link

I have another use case for this, although I don't know if the backend ipywidgets plumbing will keep operating: the jp_proxy_widget extension provides an easy way to wrap a js application in an ipywidget wrapper. At the moment, only one instance of the widget can be opened (I think...). This means that whilst the widget can be displayed as a cell output, that cell output/widget can't be opened a second time.

It would be really useful to be able to open a jp_proxy_widget directly into a new JupyterLab output window.

@dsblank
Copy link
Member

dsblank commented Jan 3, 2021

Just going to mention the ipylab project as it wasn't mentioned here before. Although, I, too, and looking for a better-integrated solution that builds on "Create new view for output".

@krassowski
Copy link
Member

So I needed to quickly check results in a pandas DataFrame using interactive filtering but did not want to install a third-party plugin; here is what you can easily achieve with sidecar + ipywidgets:

pandas_explorer-demo

Gist with code: https://gist.github.com/krassowski/159bb0c76ff47edb031710e2cff6862f

The code could be improved by rewriting the search to use regular expressions and to sanitize the cell content (html), but other than that it works fine for me. An important feature is the default limit on numer of columns and rows so that large datasets do not freeze the lab.

The only major issue is with sidecar layout preventing scrollbars from working. It was raised a few time over at the sidecar repository but it seems to receive little attention. It would really be great if someone with better understanding of the widgets system could have a look at jupyter-widgets/jupyterlab-sidecar#59 (and issues mentioned in there).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests