Skip to content

Commit b502d8e

Browse files
committed
inherit _format_attrs and _format_space
1 parent 7bc5364 commit b502d8e

File tree

2 files changed

+7
-19
lines changed

2 files changed

+7
-19
lines changed

pandas/core/indexes/multi.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -955,21 +955,6 @@ def _formatter_func(self, tup):
955955
formatter_funcs = [level._formatter_func for level in self.levels]
956956
return tuple(func(val) for func, val in zip(formatter_funcs, tup))
957957

958-
def _format_attrs(self):
959-
"""
960-
Return a list of tuples of the (attr,formatted_value)
961-
"""
962-
attrs = [('dtype', "'{}'".format(self.dtype))]
963-
if self.names is not None and any(self.names):
964-
attrs.append(('names', default_pprint(self.names)))
965-
max_seq_items = get_option('display.max_seq_items') or len(self)
966-
if len(self) > max_seq_items:
967-
attrs.append(('length', len(self)))
968-
return attrs
969-
970-
def _format_space(self):
971-
return " "
972-
973958
def _format_data(self, name=None):
974959
"""
975960
Return the formatted data as a unicode string

pandas/io/formats/printing.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -310,11 +310,12 @@ def format_object_summary(obj, formatter, is_justify=True, name=None,
310310
space2 = "\n " # space for the opening '['
311311

312312
n = len(obj)
313-
if not line_break_each_value:
314-
sep = ','
313+
if line_break_each_value:
314+
# If we want to vertically align on each value of obj, we need to
315+
# separate values by a line break and indent the values
316+
sep = ',\n ' + ' ' * len(name)
315317
else:
316-
# If we want to align on each value, we need a different separator.
317-
sep = (',\n ' + ' ' * len(name))
318+
sep = ','
318319
max_seq_items = get_option('display.max_seq_items') or n
319320

320321
# are we a truncated display
@@ -477,6 +478,8 @@ def format_object_attrs(obj):
477478
attrs.append(('dtype', "'{}'".format(obj.dtype)))
478479
if getattr(obj, 'name', None) is not None:
479480
attrs.append(('name', default_pprint(obj.name)))
481+
elif getattr(obj, 'names', None) is not None and any(obj.names):
482+
attrs.append(('names', default_pprint(obj.names)))
480483
max_seq_items = get_option('display.max_seq_items') or len(obj)
481484
if len(obj) > max_seq_items:
482485
attrs.append(('length', len(obj)))

0 commit comments

Comments
 (0)