Created
January 29, 2018 12:29
-
-
Save eiriks/60e77a6e974fd5184f0d6ffd6741d159 to your computer and use it in GitHub Desktop.
contents of: ~/.ipython/profile_default/startup/00-standard-imports.ipy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%matplotlib inline | |
%load_ext autotime | |
import pandas as pd | |
import numpy as np | |
from IPython.core.interactiveshell import InteractiveShell | |
InteractiveShell.ast_node_interactivity = "all" | |
import uuid | |
from IPython.display import display_javascript, display_html, display | |
import json | |
class RenderJSON(object): | |
def __init__(self, json_data): | |
if isinstance(json_data, dict): | |
self.json_str = json.dumps(json_data) | |
else: | |
self.json_str = json | |
self.uuid = str(uuid.uuid4()) | |
def _ipython_display_(self): | |
display_html('<div id="{}" style="height: 600px; width:100%;"></div>'.format(self.uuid), | |
raw=True | |
) | |
display_javascript(""" | |
require(["https://rawgit.com/caldwell/renderjson/master/renderjson.js"], function() { | |
document.getElementById('%s').appendChild(renderjson(%s)) | |
}); | |
""" % (self.uuid, self.json_str), raw=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment