Skip to content

Instantly share code, notes, and snippets.

@parente
Last active September 1, 2020 16:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parente/5cab90125191d523e76fcb398f30da05 to your computer and use it in GitHub Desktop.
Save parente/5cab90125191d523e76fcb398f30da05 to your computer and use it in GitHub Desktop.
Jupyter Tidbit: Display handles

Summary

IPython's display() function can return a DisplayHandle object. You can use a DisplayHandle to update the output of one cell from any other cell in a Jupyter Notebook.

Example

Binder

The display_handle.ipynb notebook below calls display(display_id=True) to get a display handle instance. It then uses the DisplayHandle.display method to show some initial, static Markdown. Later, in a different cell, it calls DisplayHandle.update in a loop to show a range of emoji characters.

Why is this useful?

You can use display handles to redraw matplotlib plots, re-render DataFrame tables, print log file updates, etc. from code executed anywhere in the notebook.

Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment