'Python Pandas Multi Index Division
foo bar baz
a x 20
y 40
z 60
b x 20
y 100
z 50
I have the above in a multi index data frame, and i want to divide the x in a by the x in b. i've tried
df.groupby(level = ['foo', 'bar']).divide('baz'))
which was recommended on another Stack thread, and it doesn't work. Not sure how to get it to effectively be a new dataframe where we have
bar a/b
x 1
y 0.4
z 1.2
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
