Skip to content

Commit 2a2d63f

Browse files
committed
inherit _format_attrs and _format_space
1 parent 6172d9a commit 2a2d63f

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
@@ -914,21 +914,6 @@ def _formatter_func(self, tup):
914914
formatter_funcs = [level._formatter_func for level in self.levels]
915915
return tuple(func(val) for func, val in zip(formatter_funcs, tup))
916916

917-
def _format_attrs(self):
918-
"""
919-
Return a list of tuples of the (attr,formatted_value)
920-
"""
921-
attrs = [('dtype', "'{}'".format(self.dtype))]
922-
if self.names is not None and any(self.names):
923-
attrs.append(('names', default_pprint(self.names)))
924-
max_seq_items = get_option('display.max_seq_items') or len(self)
925-
if len(self) > max_seq_items:
926-
attrs.append(('length', len(self)))
927-
return attrs
928-
929-
def _format_space(self):
930-
return " "
931-
932917
def _format_data(self, name=None):
933918
"""
934919
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)