From 9022f54c07465d05d185a26ca5f5e04d9992a039 Mon Sep 17 00:00:00 2001 From: Ed Bennett Date: Tue, 17 Dec 2024 20:51:00 +0000 Subject: [PATCH] avoid materialising list unnecessarily --- pandas/io/formats/style_render.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/pandas/io/formats/style_render.py b/pandas/io/formats/style_render.py index bef661e2574d6..26ca8726e52f4 100644 --- a/pandas/io/formats/style_render.py +++ b/pandas/io/formats/style_render.py @@ -956,14 +956,11 @@ def concatenated_visible_rows(obj): visible_index_levels: list[int] = [ i for i in range(index_levels) if not self.hide_index_[i] ] - target_index_levels: list[int] = [ - i - for i in range(index_levels) - if "invisible" in clines or not self.hide_index_[i] - ] for rn, r in enumerate(visible_row_indexes): lvln = 0 - for lvl in target_index_levels: + for lvl in range(index_levels): + if self.hide_index_[lvl] and "invisible" not in clines: + continue if lvl == index_levels - 1 and "skip-last" in clines: continue idx_len = d["index_lengths"].get((lvl, r), None)