@@ -419,15 +419,18 @@ def inline_index_repr(index, max_width=None):
419
419
return repr_
420
420
421
421
422
- def summarize_index (name : Hashable , index , col_width : int , max_width : int = None ):
422
+ def summarize_index (
423
+ names : tuple [Hashable ], index , col_width : int , max_width : int = None
424
+ ):
423
425
if max_width is None :
424
426
max_width = OPTIONS ["display_width" ]
425
427
426
- preformatted = pretty_print (f" { name } " , col_width )
428
+ preformatted = [ pretty_print (f" { name } " , col_width ) for name in names ]
427
429
428
- index_width = max_width - len (preformatted )
430
+ head , * tail = preformatted
431
+ index_width = max_width - len (head )
429
432
repr_ = inline_index_repr (index , max_width = index_width )
430
- return preformatted + repr_
433
+ return " \n " . join ([ head + repr_ ] + [ line . rstrip () for line in tail ])
431
434
432
435
433
436
def filter_nondefault_indexes (indexes , filter_indexes ):
@@ -446,18 +449,10 @@ def filter_nondefault_indexes(indexes, filter_indexes):
446
449
447
450
448
451
def indexes_repr (indexes , max_rows = None ):
449
- def format_names (names ):
450
- if len (names ) == 1 :
451
- return str (names [0 ])
452
- else :
453
- return f"[{ ', ' .join (str (n ) for n in names )} ]"
454
-
455
- indexes_ = {format_names (names ): idx for names , idx in indexes .items ()}
456
-
457
- col_width = _calculate_col_width (indexes_ )
452
+ col_width = _calculate_col_width (chain .from_iterable (indexes ))
458
453
459
454
return _mapping_repr (
460
- indexes_ ,
455
+ indexes ,
461
456
"Indexes" ,
462
457
summarize_index ,
463
458
"display_expand_indexes" ,
0 commit comments