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

后端 未结 11 1246
灰色年华
灰色年华 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:46

    I finally re-found the jupyter/IPython documentation that I was looking for.

    I needed this:

    from IPython.display import HTML, display
    
    data = [[1,2,3],
            [4,5,6],
            [7,8,9],
            ]
    
    display(HTML(
       '{}
    '.format( ''.join( '{}'.format(''.join(str(_) for _ in row)) for row in data) ) ))

    (I may have slightly mucked up the comprehensions, but display(HTML('some html here')) is what we needed)

提交回复
热议问题