I follow up on this question. Assume I have the following dataframe.
df = pd.DataFrame({'col1': [1, 3], 'col2': [2, 1]})
from which I can get a Latex table as
df.to_latex()
I know I can pass a formatter for each columnm as illustrated, e.g., in the above question.
My question is: How can I format the elements of col1
based on the elements of col2
and viceversa?
Assume, for example, I want to add a plus sign to a cell, if its value is higher than that of the adjacent cell, getting the following result.
\begin{tabular}{lrr}
\toprule
{} & col1 & col2 \\
\midrule
0 & 1 & +2 \\
1 & +3 & 1 \\
\bottomrule
\end{tabular}