I have a df with 2 numeric columns
DATA_ROWS = 5
df = pd.DataFrame({"id":[1]*DATA_ROWS,"x":[1,2,3,4,5],
"z":[1,1,1,5,6]})
df.set_index("id", drop=True, append=True, inplace=True)
x z
id
0 1 1 1
1 1 2 1
2 1 3 1
3 1 4 5
4 1 5 6
(id is an index)
Also, I have a list of functions
funcs = [np.max, np.min, np.std, func1, func2]
So, when I aggregate, I got
df.aggregate(funcs)
x z
amax 5.000000 6.000000
amin 1.000000 1.000000
std 1.581139 2.489980
func1 7.000000 1.000000
func2 23.500000 6.200000
I will like to get instead of this the following
x_amax, x_amin x_std x_func1 x_func2 z_amax z_amin z_std z_func1 z_func2
1 5.000 1.000 1.5811 7.000 23.500 6.000 1.000 2.4899 1.000 6.2000
I read the documentaion about pivot, melt etc and I can't get how to do this, Any ideas?