diff --git a/pandas/io/formats/string.py b/pandas/io/formats/string.py index 071afc059b166..8ad545270dec1 100644 --- a/pandas/io/formats/string.py +++ b/pandas/io/formats/string.py @@ -166,7 +166,7 @@ def _fit_strcols_to_terminal_width(self, strcols: list[list[str]]) -> str: dif = max_len - width # '+ 1' to avoid too wide repr (GH PR #17023) adj_dif = dif + 1 - col_lens = Series([Series(ele).apply(len).max() for ele in strcols]) + col_lens = Series([Series(ele).str.len().max() for ele in strcols]) n_cols = len(col_lens) counter = 0 while adj_dif > 0 and n_cols > 1: