Skip to content

Commit 8e1160d

Browse files
authored
BUG: Styler.to_latex with multirow cellcolor (#43720)
1 parent 98f7341 commit 8e1160d

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

pandas/io/formats/style_render.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,7 @@ def _translate_latex(self, d: dict) -> None:
740740
"display_value": col["display_value"]
741741
if col["is_visible"]
742742
else "",
743-
"cellstyle": self.ctx_index[r, c] if col["is_visible"] else [],
743+
"cellstyle": self.ctx_index[r, c],
744744
}
745745
for c, col in enumerate(row[:index_levels])
746746
if (col["type"] == "th" and not self.hide_index_[c])

pandas/tests/io/formats/style/test_to_latex.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,7 @@ def test_apply_map_header_render_mi(df_ext, index, columns, siunitx):
753753
expected_index = dedent(
754754
"""\
755755
\\multirow[c]{2}{*}{\\bfseries{A}} & a & 0 & -0.610000 & ab \\\\
756-
& b & 1 & -1.220000 & cd \\\\
756+
\\bfseries{} & b & 1 & -1.220000 & cd \\\\
757757
B & \\bfseries{c} & 2 & -2.220000 & de \\\\
758758
"""
759759
)
@@ -840,7 +840,7 @@ def test_latex_hiding_index_columns_multiindex_alignment():
840840
i-0 & i-2 & & & \\\\
841841
i0 & \\color{blue} j2 & \\color{red} 5 & 6 & 7 \\\\
842842
\\multirow[c]{2}{*}{\\color{blue} j0} & i2 & 9 & 10 & 11 \\\\
843-
& \\color{blue} j2 & 13 & 14 & 15 \\\\
843+
\\color{blue} & \\color{blue} j2 & 13 & 14 & 15 \\\\
844844
\\end{tabular}
845845
"""
846846
)

0 commit comments

Comments
 (0)