Skip to content

Commit 1b9ff3f

Browse files
committed
TYP: replace casting with actual int conversion
1 parent 8849a98 commit 1b9ff3f

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

pandas/io/formats/format.py

+8-11
Original file line numberDiff line numberDiff line change
@@ -793,19 +793,16 @@ def _truncate_vertically(self) -> None:
793793
self.tr_row_num = row_num
794794

795795
def _get_strcols_without_index(self) -> List[List[str]]:
796-
# TODO check this comment validity
797-
# this method is not used by to_html where self.col_space
798-
# could be a string so safe to cast
799-
col_space = {k: cast(int, v) for k, v in self.col_space.items()}
800-
801-
frame = self.tr_frame
802796
strcols: List[List[str]] = []
803797

804798
if not is_list_like(self.header) and not self.header:
805-
for i, c in enumerate(frame):
799+
for i, c in enumerate(self.tr_frame):
806800
fmt_values = self._format_col(i)
807801
fmt_values = _make_fixed_width(
808-
fmt_values, self.justify, minimum=col_space.get(c, 0), adj=self.adj
802+
strings=fmt_values,
803+
justify=self.justify,
804+
minimum=int(self.col_space.get(c, 0)),
805+
adj=self.adj,
809806
)
810807
strcols.append(fmt_values)
811808
return strcols
@@ -820,16 +817,16 @@ def _get_strcols_without_index(self) -> List[List[str]]:
820817
)
821818
str_columns = [[label] for label in self.header]
822819
else:
823-
str_columns = self._get_formatted_column_labels(frame)
820+
str_columns = self._get_formatted_column_labels(self.tr_frame)
824821

825822
if self.show_row_idx_names:
826823
for x in str_columns:
827824
x.append("")
828825

829-
for i, c in enumerate(frame):
826+
for i, c in enumerate(self.tr_frame):
830827
cheader = str_columns[i]
831828
header_colwidth = max(
832-
col_space.get(c, 0), *(self.adj.len(x) for x in cheader)
829+
int(self.col_space.get(c, 0)), *(self.adj.len(x) for x in cheader)
833830
)
834831
fmt_values = self._format_col(i)
835832
fmt_values = _make_fixed_width(

0 commit comments

Comments
 (0)