I have the following data frame, listing the spends for each category for each day
Dataframe: actualSpends
Date Category Spend ($)
2017/01/01 Apple 10
2017/01/02 Apple 12
2017/01/03 Apple 8
2017/01/01 Banana 13
2017/01/02 Banana 15
2017/01/03 Banana 7
I want to create a new data frame that will list down the average amount spend for each category, for each day of the month. (e.g. On the 3rd of the month, the average spend of all days that have passed in the month, from the 1st to 31st of each month. )
EDIT: So the output should look something like..
Date Category AvgSpend ($)
2017/01/01 Apple 10
2017/01/02 Apple 11
2017/01/03 Apple 10
2017/01/01 Banana 13
2017/01/02 Banana 14
2017/01/03 Banana 11.7
Where for each category, the average spend for each day is an average of all the days past. 1st, is an average of 1st. 2nd is an average of 1st + 2nd. 3rd is an average of 1st + 2nd + 3rd.
Is there any workaround for this?