【发布时间】:2019-04-16 02:10:01
【问题描述】:
我有带有标签 app_name、日期和总收入列的数据框,计算了窗口 2 的总收入的滚动平均值。 我对此很陌生
App_Name Date Gross Revenue
com.alpha.studio 2018-10-16 11643154
com.alpha.studio 2018-10-17 13198984
com.alpha.studio 2018-10-18 24217875
我写了这样的代码
rolling_mean = com_fivemobile_thescore['Gross Revenue'].astype(int).rolling(2).mean()
rolling_std = com_fivemobile_thescore['Gross Revenue'].astype(int).rolling(2).std()
print ("mean and std----------",rolling_mean)
得到这样的东西
65259 3352.5
231872 3245.5
226967 1936.0
162993 2583.0
237743 3190.5
228604 2550.5
219176 1698.0
预期格式是:我需要滚动平均日期
Date Gross Revenue
1 NaN
2018-10-16 3352.5
2018-10-17 3245.5
2018-10-18 2583.0
请帮忙解决这个问题
【问题讨论】:
-
再说一次,为什么你的问题在一分钟内就获得了 3 个赞?您的上一个问题在 3 分钟内获得了 4 个赞成票。这在这个标签中是闻所未闻的。
标签: pandas dataframe time-series data-science