Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 359b2a3

Browse files
committedSep 2, 2018
inherit _format_attrs and _format_space
1 parent bba70b2 commit 359b2a3

File tree

2 files changed

+7
-19
lines changed

2 files changed

+7
-19
lines changed
 

‎pandas/core/indexes/multi.py

-15
Original file line numberDiff line numberDiff line change
@@ -615,21 +615,6 @@ def _formatter_func(self, tup):
615615
formatter_funcs = [level._formatter_func for level in self.levels]
616616
return tuple(func(val) for func, val in zip(formatter_funcs, tup))
617617

618-
def _format_attrs(self):
619-
"""
620-
Return a list of tuples of the (attr,formatted_value)
621-
"""
622-
attrs = [('dtype', "'{}'".format(self.dtype))]
623-
if self.names is not None and any(self.names):
624-
attrs.append(('names', default_pprint(self.names)))
625-
max_seq_items = get_option('display.max_seq_items') or len(self)
626-
if len(self) > max_seq_items:
627-
attrs.append(('length', len(self)))
628-
return attrs
629-
630-
def _format_space(self):
631-
return " "
632-
633618
def _format_data(self, name=None):
634619
"""
635620
Return the formatted data as a unicode string

‎pandas/io/formats/printing.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -306,11 +306,12 @@ def format_object_summary(obj, formatter, is_justify=True,
306306
space2 = "\n%s" % (' ' * (len(name) + 2))
307307

308308
n = len(obj)
309-
if not line_break_each_value:
310-
sep = ','
309+
if line_break_each_value:
310+
# If we want to vertically align on each value of obj, we need to
311+
# separate values by a line break and indent the values
312+
sep = ',\n ' + ' ' * len(name)
311313
else:
312-
# If we want to align on each value, we need a different separator.
313-
sep = (',\n ' + ' ' * len(name))
314+
sep = ','
314315
max_seq_items = get_option('display.max_seq_items') or n
315316

316317
# are we a truncated display
@@ -467,6 +468,8 @@ def format_object_attrs(obj):
467468
attrs.append(('dtype', "'{}'".format(obj.dtype)))
468469
if getattr(obj, 'name', None) is not None:
469470
attrs.append(('name', default_pprint(obj.name)))
471+
elif getattr(obj, 'names', None) is not None and any(obj.names):
472+
attrs.append(('names', default_pprint(obj.names)))
470473
max_seq_items = get_option('display.max_seq_items') or len(obj)
471474
if len(obj) > max_seq_items:
472475
attrs.append(('length', len(obj)))

0 commit comments

Comments
 (0)
Please sign in to comment.