How to capture rich display using %%capture or similar magics?

547 views
Skip to first unread message

Paul A

unread,
Aug 8, 2016, 7:43:44 AM8/8/16
to Project Jupyter
%%capture does not seem to capture rich output, such as pandas dataframe or interactive widgets. Could anyone suggest examples/ways to intercept those?

Thomas Kluyver

unread,
Aug 8, 2016, 7:54:52 AM8/8/16
to Project Jupyter
It should do. Make sure that your IPython is up to date.

On 8 August 2016 at 12:43, Paul A <rootsum...@gmail.com> wrote:
%%capture does not seem to capture rich output, such as pandas dataframe or interactive widgets. Could anyone suggest examples/ways to intercept those?

--
You received this message because you are subscribed to the Google Groups "Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jupyter+unsubscribe@googlegroups.com.
To post to this group, send email to jup...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jupyter/561cab7e-4522-4f88-8630-3f5dc4265ca9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Paul A

unread,
Aug 9, 2016, 8:22:33 AM8/9/16
to Project Jupyter


On Monday, August 8, 2016 at 12:54:52 PM UTC+1, takowl wrote:
It should do. Make sure that your IPython is up to date.
On 8 August 2016 at 12:43, Paul A <rootsum...@gmail.com> wrote:
%%capture does not seem to capture rich output, such as pandas dataframe or interactive widgets. Could anyone suggest examples/ways to intercept those?

--
You received this message because you are subscribed to the Google Groups "Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jupyter+u...@googlegroups.com.

MinRK

unread,
Aug 9, 2016, 8:50:05 AM8/9/16
to Project Jupyter
The capture magic captures any explicit displayed/printed output. It does not include the *result* of the computation, triggered by the displayhook. If you called, instead, `display(df)`, it would capture it.

We could capture the result as well, though part of the impetus for this utilitiy was for output-flooding libraries, where you may just want to suppress all the side-effect output on your way to a result, and only look at it if something failed. In this use case, also hiding results wouldn't be desirable, but I can see how the current behavior might be surprising.

-MinRK

To unsubscribe from this group and stop receiving emails from it, send an email to jupyter+unsubscribe@googlegroups.com.

To post to this group, send email to jup...@googlegroups.com.

Thomas Kluyver

unread,
Aug 9, 2016, 9:05:50 AM8/9/16
to Project Jupyter
I'm working on a PR to capture the result as well.

Thomas Kluyver

unread,
Aug 9, 2016, 9:13:00 AM8/9/16
to Project Jupyter
I'm not sure if that's what we want to do, but there's what it would take.
Reply all
Reply to author
Forward
0 new messages