I have two pandas dataframes and I would like to display them in Jupyter notebook.
Doing something like:
display(df1)
display(df2)
Extension of antony's answer If you want to limit de visualization of tables to some numer of blocks by row, use the maxTables variable.
def mydisplay(dfs, names=[]):
count = 0
maxTables = 6
if not names:
names = [x for x in range(len(dfs))]
html_str = ''
html_th = ''
html_td = ''
for df, name in zip(dfs, names):
if count <= (maxTables):
html_th += (''.join(f'{name} '))
html_td += (''.join(f' {df.to_html(index=False)} '))
count += 1
else:
html_str += f'{html_th} {html_td} '
html_th = f'{name} '
html_td = f' {df.to_html(index=False)} '
count = 0
if count != 0:
html_str += f'{html_th} {html_td} '
html_str += f'{html_str}
'
html_str = html_str.replace('table','table style="display:inline"')
display_html(html_str, raw=True)