How do I output lists as a table in Jupyter notebook?

后端 未结 11 1025
灰色年华
灰色年华 2021-01-30 09:51

I know that I\'ve seen some example somewhere before but for the life of me I cannot find it when googling around.

I have some rows of data:

data = [[1,2         


        
11条回答
  •  孤城傲影
    2021-01-30 10:45

    I just discovered that tabulate has a HTML option and is rather simple to use.
    Quite similar to Wayne Werner's answer:

    from IPython.display import HTML, display
    import tabulate
    table = [["Sun",696000,1989100000],
             ["Earth",6371,5973.6],
             ["Moon",1737,73.5],
             ["Mars",3390,641.85]]
    display(HTML(tabulate.tabulate(table, tablefmt='html')))
    

    Still looking for something simple to use to create more complex table layouts like with latex syntax and formatting to merge cells and do variable substitution in a notebook:
    Allow references to Python variables in Markdown cells #2958

提交回复
热议问题