1import pandas as pd
2import numpy as np
3df = pd.DataFrame(np.random.randn(6,4),columns=list('ABCD'))
4# Show in Jupyter
5df
6
7from IPython.display import HTML
8s = '<script type="text/Javascript">'
9s += 'var win = window.open("", "Title", "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=780, height=200, top="+(screen.height-400)+", left="+(screen.width-840));'
10s += 'win.document.body.innerHTML = \'' + df.to_html().replace("\n",'\\') + '\';'
11s += '</script>'
12
13# Show in new Window
14HTML(s)
1def View(df):
2 css = """<style>
3 table { border-collapse: collapse; border: 3px solid #eee; }
4 table tr th:first-child { background-color: #eeeeee; color: #333; font-weight: bold }
5 table thead th { background-color: #eee; color: #000; }
6 tr, th, td { border: 1px solid #ccc; border-width: 1px 0 0 1px; border-collapse: collapse;
7 padding: 3px; font-family: monospace; font-size: 10px }</style>
8 """
9 s = '<script type="text/Javascript">'
10 s += 'var win = window.open("", "Title", "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=780, height=200, top="+(screen.height-400)+", left="+(screen.width-840));'
11 s += 'win.document.body.innerHTML = \'' + (df.to_html() + css).replace("\n",'\\') + '\';'
12 s += '</script>'
13
14 return(HTML(s+css))