pandas dataframe as latex or html table nbconvert

后端 未结 3 1091
孤街浪徒
孤街浪徒 2020-12-28 10:39

Is it possible to get a nicely formatted table from a pandas dataframe in ipython notebook when using nbconvert to latex & PDF?

The default seems to be just a le

3条回答
  •  执念已碎
    2020-12-28 11:19

    The simplest way available now is to display your dataframe as a markdown table. You may need to install tabulate for this.

    In your code cell, when displaying dataframe, use following:

    from IPython.display import Markdown, display
    display(Markdown(df.to_markdown()))
    

    Since it is a markdown table, nbconvert can easily translate this into latex.

提交回复
热议问题