Skip to content

Commit 93802f2

Browse files
Apply suggested fix
Co-authored-by: JHM Darbyshire <[email protected]>
1 parent a505fe9 commit 93802f2

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

pandas/io/formats/style_render.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -868,9 +868,9 @@ def _translate_latex(self, d: dict, clines: str | None) -> None:
868868
or multirow sparsification (so that \multirow and \multicol work correctly).
869869
"""
870870
index_levels = self.index.nlevels
871-
visible_index_level_n = index_levels - sum(self.hide_index_)
872-
if visible_index_level_n == 0:
873-
visible_index_level_n = 1
871+
# d["head"] will contain at least one column relating to the index,
872+
# it will be marked as `is_visible`: False if all levels are hidden
873+
visible_index_level_n = max(1, index_levels - sum(self.hide_index_))
874874
d["head"] = [
875875
[
876876
{**col, "cellstyle": self.ctx_columns[r, c - visible_index_level_n]}

0 commit comments

Comments
 (0)