重新采样数据框架和分配新样本频率的值
如何使用respample()对数据框进行示例示例以使初始值分配在新的示例频率上?
样本频率的数据
date revenue
0 2021-11-01 00:00:00+00:00 300
1 2021-10-01 00:00:00+00:00 500
2 2021-09-01 00:00:00+00:00 100
3 2021-08-01 00:00:00+00:00 50
4 2021-07-01 00:00:00+00:00 200
5 2021-06-01 00:00:00+00:00 150
带有每月
revenue
date
2021-06-01 00:00:00+00:00 4.8
2021-06-02 00:00:00+00:00 4.8
2021-06-03 00:00:00+00:00 4.8
2021-06-04 00:00:00+00:00 4.8
2021-06-05 00:00:00+00:00 4.8
... ...
2021-11-28 00:00:00+00:00 9.6
2021-11-29 00:00:00+00:00 9.6
2021-11-30 00:00:00+00:00 9.6
2021-11-31 00:00:00+00:00 9.6
框
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用
asfreq
将时间表从每月转换为每日频率,然后使用ffill
转发填充值,然后将Revenue
划分为daysinmonth
dateTimeIndex的属性
计算分布式收入You can use
asfreq
to convert the timeseries from monthly to daily frequency, then useffill
to forward fill the values then divide therevenue
bydaysinmonth
attribute ofdatetimeindex
to calculate distributed revenue