BUG: Styler.to_latex permanently impacts table_styles for successive calls · Issue #42320 · pandas-dev/pandas (original) (raw)

For

styler = DataFrame([[1]]).style

doing

styler.to_latex(hrules=True) (or any other kw argument which impacts table_styles)

results in:

\begin{tabular}{lr}
\toprule
{} & {0} \\
\midrule
0 & 1 \\
\bottomrule
\end{tabular}

Now doing

styler.to_latex(hrules=False)

still results in

\begin{tabular}{lr}
\toprule
{} & {0} \\
\midrule
0 & 1 \\
\bottomrule
\end{tabular}

because the table_styles attribute on styler has been overwritten by first call which dominates the second.