Pandas Pivot Table Dictionary of Agg function
I am trying to calculate 3 aggregative
functions during pivoting:
- Count
- Mean
- StDev
This is the code:
n_page = (pd.pivot_table(Main_DF,
values='SPC_RAW_VALUE',
index=['ALIAS', 'SPC_PRODUCT', 'LABLE', 'RAW_PARAMETER_NAME'],
columns=['LOT_VIRTUAL_LINE'],
aggfunc={'N': 'count', 'Mean': np.mean, 'Sigma': np.std})
.reset_index()
)
Error I am getting is: KeyError: 'Mean'
How can I calculate those 3 functions?