I'm getting a ValueError when applying np.sum that I need to product aggregated value. Any word of advise to fix this issue? Btw - This logic used to run for me before.
df1 =
self_id | id | rating | comment |
1 820 (blank) (blank)
2 823 strong good performance
3 826 weak (blank)
#Pivoting the NaNs/unique values
ndf1 = pd.pivot_table(data=df1, index=['self_id'],
aggfunc={'id':np.unique,
'Ratings':np.sum,
'Comments':np.sum})
ValueError: Must produce aggregated value
Thank you in advance!
np.sumreturn a unique element per group (its sum), whilenp.uniquereturns an array. There is an internal check to return this error when an non object array is returned.You could convert to list to avoid this issue:
Output: