@@ -92,15 +92,17 @@ def __init__(
92
92
self .label = label
93
93
self .position = position
94
94
95
+ self .strcols = self ._get_strcols ()
96
+ self .strrows = list (zip (* self .strcols ))
97
+
95
98
def write_result (self , buf : IO [str ]) -> None :
96
99
"""
97
100
Render a DataFrame to a LaTeX tabular, longtable, or table/tabular
98
101
environment output.
99
102
"""
100
103
buf .write (self ._compose_string ())
101
104
102
- @property
103
- def strcols (self ):
105
+ def _get_strcols (self ):
104
106
"""String representation of the columns."""
105
107
if len (self .frame .columns ) == 0 or len (self .frame .index ) == 0 :
106
108
info_line = (
@@ -145,10 +147,6 @@ def pad_empties(x):
145
147
strcols = out + strcols [1 :]
146
148
return strcols
147
149
148
- @property
149
- def strrows (self ):
150
- return list (zip (* self .strcols ))
151
-
152
150
@property
153
151
def column_format (self ):
154
152
return self ._column_format
@@ -242,8 +240,7 @@ def _compose_env_body(self):
242
240
return "\n " .join (body_list )
243
241
244
242
def _compose_row (self , row_num ):
245
- strrows = self .strrows
246
- row = strrows [row_num ]
243
+ row = self .strrows [row_num ]
247
244
248
245
is_multicol = row_num < self ._clevels and self .fmt .header and self .multicolumn
249
246
@@ -261,7 +258,7 @@ def _compose_row(self, row_num):
261
258
if is_multicol :
262
259
crow = self ._format_multicolumn (crow )
263
260
if is_multirow :
264
- crow = self ._format_multirow (crow , row_num , strrows )
261
+ crow = self ._format_multirow (crow , row_num )
265
262
266
263
lst = []
267
264
lst .append (" & " .join (crow ))
@@ -347,9 +344,7 @@ def append_col():
347
344
append_col ()
348
345
return row2
349
346
350
- def _format_multirow (
351
- self , row : List [str ], i : int , rows : List [Tuple [str , ...]]
352
- ) -> List [str ]:
347
+ def _format_multirow (self , row : List [str ], i : int ) -> List [str ]:
353
348
r"""
354
349
Check following rows, whether row should be a multirow
355
350
@@ -362,7 +357,7 @@ def _format_multirow(
362
357
for j in range (self ._ilevels ):
363
358
if row [j ].strip ():
364
359
nrow = 1
365
- for r in rows [i + 1 :]:
360
+ for r in self . strrows [i + 1 :]:
366
361
if not r [j ].strip ():
367
362
nrow += 1
368
363
else :
0 commit comments