Reputation: 10033
How can I get this pivot table:
mean
points_num
round position
1 FWD 2.445283
MID 1.628571
DEF 2.378571
2 FWD 3.000000
MID 2.651351
DEF 1.930435
df.columns
:
[108 rows x 1 columns]
MultiIndex([('mean', 'points_num')],
)
And change it into a dataframe like so:
Round FWD MID DEF
1 2.445283 1.628571 2.378571
2 3.000000 2.651351 1.930435
Upvotes: 0
Views: 21
Reputation: 150745
Can you try:
pivot_df.iloc[:,0].unstack('position')
However, you can probably be better off using pivot_table
on the original dataframe:
df.pivot_table(index='round', column='position',
values='points_num', aggfunc='mean'
)
Upvotes: 1