Skip to content

Conditional HTML styling hides MultiIndex structure #11655

Closed
@mattilyra

Description

@mattilyra

I noticed that the styling doesn't quite work with MultiIndex data frames. For example if we have a dataframe with two cross validated scores and take their meanand sem using groupby to get a MultiIndex dataframe

import itertools
import pandas as pd
import numpy as np

jobs = itertools.product(['a', 'b', 'c', 'd'], np.arange(1e-4, 1e-3, .0003), range(10))
rows = []
for v, v2, itr in jobs:
    rows.append({'param_1': v, 'param_2': v2, 'iter': itr,
                 'score_1': np.random.randint(0, 100, size=(1,))[0],
                 'score_2': np.random.rand(1, )[0]})
df_multi = pd.DataFrame(rows)
agg = df_multi.groupby(by=['param_1', 'param_2'])[['score_1', 'score_2']].agg(['mean', 'sem'])
agg.style.highlight_max()

screen shot 2015-11-20 at 12 04 13

where as without the styling the index names are preserved and the score_1 and score_2 column headers span 2 columns which improves legibility.

screen shot 2015-11-20 at 12 02 56

Metadata

Metadata

Assignees

No one assigned

    Labels

    IO HTMLread_html, to_html, Styler.apply, Styler.applymapMultiIndexOutput-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