Created
September 30, 2020 19:03
-
-
Save Per48edjes/42efaa6f2eab3c40510427954d58b72e to your computer and use it in GitHub Desktop.
Display dataframes in a row with captions
This file contains hidden or 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
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