I have a time-series DataFrame of sales, I need to calculate the average share of sales for each day of the week. Below is an example of what I want:
df1
: time series dataframe for sales.share_sales_week_of_day
- wanted DataFrame. For Mondays I have calculated real value. Here28
and42
= total week sales for every week from dataframe,1
and8
= sales on Mondays.
Code:
df1 = pd.DataFrame(index = ['2011-01-31', '2011-02-01', '2011-02-01', '2011-02-02', '2011-02-03', '2011-02-04', '2011-02-05', '2011-02-06', '2011-02-07', '2011-02-08', '2011-02-09', '2011-02-10', '2011-02-11', '2011-02-12'],
data = [1,2,3,4,5,6,7, 8,8,8,3,4,5,6], columns = ['sales'])
share_sales_week_of_day = pd.DataFrame(data = {'d_1' : [0.5*(1.0/28 + 8.0/42)],'d_2' : [0], 'd_3' : [0], 'd_4' : [0], 'd_5' : [0], 'd_6' : [0], 'd_7' : [0]})
Can you explain how can I calculate shares for whole data....