Skip to content

ENH: Add option for bold_column_headers to to_latex() #46790

Open
@mosc9575

Description

@mosc9575

In the latest pandas version 1.4.2 there exists an option to enable bold rows but there isn't a similar option to do the same for the columns. It is something some users on SO were asking for and it seems very logical.

The example from the official documentation with bold_rows=True and bold_column_headers=True should lead to the following example.

import pandas as pd

df = pd.DataFrame(
    dict(name=['Raphael', 'Donatello'],
         mask=['red', 'purple'],
         weapon=['sai', 'bo staff']
        )
)
result= df.to_latex(bold_rows=True, bold_column_headers=True)

>>> result
\begin{tabular}{llll}
\toprule
{} &       \textbf{name} &    \textbf{mask} &    \textbf{weapon} \\
\midrule
\textbf{0} &    Raphael &     red &       sai \\
\textbf{1} &  Donatello &  purple &  bo staff \\
\bottomrule
\end{tabular}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions