This can help you:
import pandas as pd
import numpy as np
arrays = [np.array(["bar", "bar", "baz", "baz", "foo", "foo", "qux", "qux"]),np.array(["one", "two", "one", "two", "one", "two", "one", "two"])]
df = pd.DataFrame(np.random.randn(8, 4), index=arrays)
df.reset_index().groupby(["level_0"]).apply(lambda x: x.sort_values([3], ascending = False)).set_index(['level_0','level_1'])
In your case 3
is your column n * %
, level_0
is your index TestName
and level_1
is your TestResult.Outcome
.
Becomes:
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…