Jupyter notebook display two pandas tables side by side

后端 未结 12 1920
迷失自我
迷失自我 2020-12-04 04:56

I have two pandas dataframes and I would like to display them in Jupyter notebook.

Doing something like:

display(df1)
display(df2)

12条回答
  •  攒了一身酷
    2020-12-04 05:33

    I ended up using HBOX

    import ipywidgets as ipyw
    
    def get_html_table(target_df, title):
        df_style = target_df.style.set_table_attributes("style='border:2px solid;font-size:10px;margin:10px'").set_caption(title)
        return df_style._repr_html_()
    
    df_2_html_table = get_html_table(df_2, 'Data from Google Sheet')
    df_4_html_table = get_html_table(df_4, 'Data from Jira')
    ipyw.HBox((ipyw.HTML(df_2_html_table),ipyw.HTML(df_4_html_table)))
    

提交回复
热议问题