Skip to content

Instantly share code, notes, and snippets.

@ksomemo
Last active July 24, 2017 02:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ksomemo/d3d1a47baebcceeafef949895612ec92 to your computer and use it in GitHub Desktop.
Save ksomemo/d3d1a47baebcceeafef949895612ec92 to your computer and use it in GitHub Desktop.
Notebookに複数のDataFrameを(水平に)出力する+displayについて
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:]
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.
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)
# print
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