diff --git a/pandas/io/formats/latex.py b/pandas/io/formats/latex.py index 4bc9da96885f1..b2622e61896a0 100644 --- a/pandas/io/formats/latex.py +++ b/pandas/io/formats/latex.py @@ -160,8 +160,7 @@ def _get_strcols(self) -> list[list[str]]: def pad_empties(x): for pad in reversed(x): if pad: - break - return [x[0]] + [i if i else " " * len(pad) for i in x[1:]] + return [x[0]] + [i if i else " " * len(pad) for i in x[1:]] gen = (pad_empties(i) for i in out) diff --git a/pandas/io/formats/printing.py b/pandas/io/formats/printing.py index 0338cb018049b..9aa10b7508b4f 100644 --- a/pandas/io/formats/printing.py +++ b/pandas/io/formats/printing.py @@ -419,9 +419,9 @@ def best_len(values: list[str]) -> int: for max_items in reversed(range(1, len(value) + 1)): pprinted_seq = _pprint_seq(value, max_seq_items=max_items) if len(pprinted_seq) < max_space: + head = [_pprint_seq(x, max_seq_items=max_items) for x in head] + tail = [_pprint_seq(x, max_seq_items=max_items) for x in tail] break - head = [_pprint_seq(x, max_seq_items=max_items) for x in head] - tail = [_pprint_seq(x, max_seq_items=max_items) for x in tail] summary = "" line = space2 diff --git a/pandas/io/formats/style.py b/pandas/io/formats/style.py index 4d685bd8e8858..16e0bd572e5d1 100644 --- a/pandas/io/formats/style.py +++ b/pandas/io/formats/style.py @@ -2298,8 +2298,8 @@ def set_sticky( "selector": f"thead tr:nth-child({obj.nlevels+1}) th", "props": props + ( - f"top:{(i+1) * pixel_size}px; height:{pixel_size}px; " - "z-index:2;" + f"top:{(len(levels_)) * pixel_size}px; " + f"height:{pixel_size}px; z-index:2;" ), } ) diff --git a/pandas/tests/frame/test_iteration.py b/pandas/tests/frame/test_iteration.py index c6e5aa6f86d29..154dee23e6042 100644 --- a/pandas/tests/frame/test_iteration.py +++ b/pandas/tests/frame/test_iteration.py @@ -159,4 +159,4 @@ def test_sequence_like_with_categorical(self): str(s) for c, col in df.items(): - str(s) + str(col) diff --git a/pyproject.toml b/pyproject.toml index b649dc0c339f4..35171291bfaf9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -217,6 +217,7 @@ disable = [ "too-many-public-methods", "too-many-return-statements", "too-many-statements", + "undefined-loop-variable", "unexpected-keyword-arg", "ungrouped-imports", "unsubscriptable-object", @@ -277,7 +278,6 @@ disable = [ "signature-differs", "super-init-not-called", "try-except-raise", - "undefined-loop-variable", "unnecessary-lambda", "unspecified-encoding", "unused-argument",