【发布时间】:2019-09-17 08:00:38
【问题描述】:
我正在使用来自 tableau (https://community.tableau.com/thread/194200) 的时间序列数据集,其中包含每日家具销售额,我想重新采样以获得平均每月销售额。
我尝试在 Pandas 中使用 resample 来获得月平均值:
There are four days in January selling furniture,
and there is no sales in the rest of Jan.
Order Date Sales
...
2014/1/6 2573.82
2014/1/7 76.728
2014/1/16 127.104
2014/1/20 38.6
...
y_furniture = furniture['Sales'].resample('MS').mean()
我希望结果是每月的实际平均销售额。
也就是说,所有的日销售额加起来除以 31 天,即 90.85,但代码将总和除以 4,约为 704。这并不能正确反映实际的月销售额。
有人知道如何解决这个问题吗?
【问题讨论】:
标签: python-3.x pandas time-series