Custom rendering from python object

Hey, I have some python calculations which are being done and all the data is being stored as possibly a json or a string object.
I would like to create a custom renderer for this, such that it reads this json object and renders a react widget.
How can I do the same?
For example I have:
'[{"time":"2019-10-22","open":245.0,"high":251.1,"low":244.95,"close":248.9,"volume":18275636.0},{"time":"2019-10-23","open":250.4,"high":251.95,"low":249.05,"close":251.05,"volume":12831461.0},{"time":"2019-10-24","open":252.6,"high":254.0,"low":247.95,"close":249.05,"volume":16791340.0},{"time":"2019-10-25","open":256.
The above json saved in a variable, and I would like to render it using my own react widget rather than the text/plain method shown below using kernelSpy
image

Customising the default renderer for a generic type like a dict is possible, but highly recommended against for the simple reason that it’s not performant or cooperative with other people intending to do the same.

Instead, if you want to render data, I’d advise either creating a custom type for which you can register a MIME renderer, or to create a dedicated function that invokes IPython.display for your special dict.

1 Like