Last active
July 24, 2017 02:31
-
-
Save ksomemo/d3d1a47baebcceeafef949895612ec92 to your computer and use it in GitHub Desktop.
Notebookに複数のDataFrameを(水平に)出力する+displayについて
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
import pandas as pd | |
import IPython.core.display as display | |
import IPython.display | |
""" | |
↑ | |
from IPython.core.display import * | |
from IPython.lib.display import * | |
lib.display includes | |
__all__ = ['Audio', 'IFrame', 'YouTubeVideo', 'VimeoVideo', 'ScribdDocument', | |
'FileLink', 'FileLinks'] | |
""" | |
df = pd.DataFrame(dict(a=range(4))) | |
print("index: 0 (print)") | |
IPython.display.display(df[0:1]) | |
print("index: 1 (print)") | |
display.display(df[1:2]) | |
print("index: 2 (print)") | |
display.display_html(df[2:3]) | |
print("index: 3 (Out to Cell)") | |
df[3:] |
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
class HorizontalDisplay: | |
def __init__(self, *args): | |
self.args = args | |
def _repr_html_(self): | |
template = '<div style="float: left; padding: 10px;">{0}</div>' | |
return "\n".join(template.format(arg._repr_html_()) | |
for arg in self.args) | |
display(HorizontalDisplay(df, df)) | |
# output | |
HorizontalDisplay(df, df) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment