I would like to convert a result output in series back to a dataframe, so that I can do further analysis. This is my data
import random
import pandas as pd
random.seed(100)
datadict = {"AB" : ["A", "B"]*6, "CDE" : ["C", "D", "E"]*4, "1234":
[random.randint(1,5) for x in range(12)], "value":
[random.randrange(1,100) for x in range(12)]}
df = pd.DataFrame(datadict)
df.groupby(["AB", "CDE", "1234"]).value.mean()
Now, I get the results in series
AB CDE 1234
A C 2 95
4 27
D 1 99
4 85
E 1 30
4 34
B C 2 7
5 40
D 4 59
5 43
E 1 27
3 83
Now, I would like to convert this result back to a dataframe, so that the data would looks like this
AB CDE 1234 mean
A C 2 95
A C 4 27
A D 1 99
A D 4 85
A E 1 30
A E 4 34
B C 2 7
B C 5 40
B D 4 59
B D 5 43
B E 1 27
B E 3 83
In this way, I can do further analysis. Can anyone tell how to do it?