WIP: Better formatting for .set_precision by mattilyra · Pull Request #11667 · pandas-dev/pandas (original) (raw)
I found some extra time behind the sofa and started working on this. I made quite a few additions but by default everything should work as it did.
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'])
crazy awesome new formatting (forget that the kwarg
is called column_formats
that's been changed to subsets
)