let's have a DataFrame
dft = pd.DataFrame({'A': (1,2,3,1,2,3),
'B': [10*i for i in range(6)],
'C': ("a", "a", "a", "b", "b", "b")}).set_index(["C", "A"])
B
C A
a 1 0
2 10
3 20
b 1 30
2 40
3 50
I'd need to interpret column B as value normed by value B of second index "A" == 2.
B
C A
a 1 0.000
2 1.000
3 2.000
b 1 0.750
2 1.000
3 1.200
It looks so easy. I've experimented with groupby, transform ... and cannot make it done.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…