File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -1444,7 +1444,10 @@ def _generate_display_table(
1444
1444
column_values = gt.gt._get_column_of_values(built_gt, column_name=column, context="html")
1445
1445
1446
1446
# Get the maximum number of characters in the column
1447
- max_length_col_vals.append(max([len(str(val)) for val in column_values]))
1447
+ if column_values: # Check if column_values is not empty
1448
+ max_length_col_vals.append(max([len(str(val)) for val in column_values]))
1449
+ else:
1450
+ max_length_col_vals.append(0) # Use 0 for empty columns
1448
1451
1449
1452
length_col_names = [len(column) for column in col_dtype_dict.keys()]
1450
1453
length_data_types = [len(dtype) for dtype in col_dtype_dict_short.values()]
@@ -1515,8 +1518,12 @@ def _generate_display_table(
1515
1518
1516
1519
# Get the highest number in the `row_number_list` and calculate a width that will
1517
1520
# safely fit a number of that magnitude
1518
- max_row_num = max(row_number_list)
1519
- max_row_num_width = len(str(max_row_num)) * 7.8 + 10
1521
+ if row_number_list: # Check if list is not empty
1522
+ max_row_num = max(row_number_list)
1523
+ max_row_num_width = len(str(max_row_num)) * 7.8 + 10
1524
+ else:
1525
+ # If row_number_list is empty, use a default width
1526
+ max_row_num_width = 7.8 * 2 + 10 # Width for 2-digit numbers
1520
1527
1521
1528
# Update the col_width_dict to include the row number column
1522
1529
col_width_dict = {"_row_num_": f"{max_row_num_width}px"} | col_width_dict
You can’t perform that action at this time.
0 commit comments