util.py 文件源码

python
阅读 32 收藏 0 点赞 0 评论 0

项目:q2templates 作者: qiime2 项目源码 文件源码
def df_to_html(df, border=0, classes=('table', 'table-striped', 'table-hover'),
               **kwargs):
    """Convert a dataframe to HTML without truncating contents.

    pandas will truncate cell contents that exceed 50 characters by default.
    Use this function to avoid this truncation behavior.

    This function uses different default parameters than `DataFrame.to_html` to
    give uniform styling to HTML tables that are compatible with q2template
    themes. These parameters can be overridden, and they (along with any other
    parameters) will be passed through to `DataFrame.to_html`.

    Parameters
    ----------
    df : pd.DataFrame
        DataFrame to convert to HTML.
    kwargs : dict
        Parameters passed through to `pd.DataFrame.to_html`.

    Returns
    -------
    str
        DataFrame converted to HTML.

    References
    ----------
    .. [1] https://stackoverflow.com/q/26277757/3776794
    .. [2] https://github.com/pandas-dev/pandas/issues/1852

    """
    with pd.option_context('display.max_colwidth', -1):
        return df.to_html(border=border, classes=classes, **kwargs)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号