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

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

    There is a nice trick: wrap the data with pandas DataFrame.

    import pandas as pd
    data = [[1, 2], [3, 4]]
    pd.DataFrame(data, columns=["Foo", "Bar"])
    

    It displays data like:

      | Foo | Bar |
    0 | 1   | 2   |
    1 | 3   | 4   |
    

提交回复
热议问题