Skip to content

MultiIndex smart repr fmt doesn't work well for complex examples #3347

@ghost

Description

In [42]: labels = [('foo', 1),
    ...:  ('foo', 2),
    ...:  ('bar', 3),
    ...:  ('bar', 4)]
    ...: pd.MultiIndex.from_tuples(labels)
Out[42]: 
MultiIndex
[foo  1,      2, bar  3,      4]

hiding the repeated foo and bar is nice for small multindices, but
for more levels and more complex structures, it can becomes
harder to read. The blanks also keep their width, and the result
isn't very attractive when presented as a single line:

labels = [('foo', '2012-07-26T00:00:00', 'b5c2700'),
    ...:  ('foo', '2012-08-06T00:00:00', '900b2ca'),
    ...:  ('foo', '2012-08-15T00:00:00', '07f1ce0'),
    ...:  ('foo', '2012-09-25T00:00:00', '5c93e83'),
    ...:  ('foo', '2012-09-25T00:00:00', '9345bba')]
    ...: pd.MultiIndex.from_tuples(labels)

MultiIndex
[append_frame_single_homogenous  2012-07-26  b5c2700,                     2012-08-06  00b2ca,                                 2012-08-15  07f1ce0,                                 2012-09-25  5c93e83,                                             9345bba]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Output-Formatting__repr__ of pandas objects, to_string

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions