Closed
Description
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 mean
and 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()
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.