There are 3 columns,
ACCOUNT, DATE, AMOUNT
I am trying to do the following in pandas, and plan to use the "sum" column after the group by output dataframe to do more works:
df_group_by=df.groupby('account').agg({'amount': [np.size, np.sum]},as_index=False).reset_index() # equal to "SELECT ACCOUNT, SUM(amount) as sum FROM table GROUP BY ACCOUNT;"
print (df_group['sum'])
and then I got the following error message:
KeyError: 'sum
I don't understand. Anyone could help? Thank you!
I am in python 3.6 & pandas 0.19.2