python 对DataFrame类型表按周聚合计算平均值

df = pandas.read_excel('test.xlsx')
df = pandas.pivot_table(df, index=['a'], columns=['b'], aggfunc=numpy.sum)

先用pivot table 把表变成这样
pv uv
20180105 1 1
20180106 1 1
20180107 1 1
20180108 1 1
20180109 1 1
20180110 1 1
20180111 1 1
20180112 2 2
20180113 2 2
20180114 2 2
20180115 2 2
20180116 2 2
20180117 2 2
20180118 2 2

想计算周日均数据变成这样
pv uv
20180105~20180111 1 1
20180111~20180118 2 2

https://jingyan.baidu.com/article/2d5afd69ef4fcf85a2e28ef6.html

http://www.mamicode.com/info-detail-1822406.html
我也在找,终于找到了

https://www.cnblogs.com/splended/p/5278078.html