获取时间day属性,生成一个新的列
detail.loc[:,'day'] = [i.day for i in detail.loc[:,'place_order_time']]
新建价格的列
detail.loc[:,'price'] = detail.loc[:,'counts']*detail.loc[:,'amounts']
按天分组求每日的营业额
res = detail.groupby(by='day')['price'].sum()
![]()
res是series,如何将series转成dataframe
#res.values是行列之间的数据,money是列,index是行索引 df = pd.DataFrame(res.values,columns=['money'],index=res.index) print(df)