Skip to content

Instantly share code, notes, and snippets.

@Per48edjes
Created September 30, 2020 19:03
Show Gist options
  • Save Per48edjes/42efaa6f2eab3c40510427954d58b72e to your computer and use it in GitHub Desktop.
Save Per48edjes/42efaa6f2eab3c40510427954d58b72e to your computer and use it in GitHub Desktop.
Display dataframes in a row with captions
from IPython.core.display import display, HTML
def display_side_by_side(dfs:list, captions:list):
"""Display tables side by side to save vertical space
Input:
dfs: list of pandas.DataFrame
captions: list of table captions
"""
output = ""
combined = dict(zip(captions, dfs))
for caption, df in combined.items():
output += df.style.set_table_attributes("style='display:inline'").set_caption(caption)._repr_html_()
output += "\xa0\xa0\xa0"
display(HTML(output))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment