我知道可以用这个periods
论点来抵消,但是如何将分布在一个月内(例如交易日)的每日价格数据返回化?
示例数据是:
In [1]: df.AAPL
2009-01-02 16:00:00 90.36
2009-01-05 16:00:00 94.18
2009-01-06 16:00:00 92.62
2009-01-07 16:00:00 90.62
2009-01-08 16:00:00 92.30
2009-01-09 16:00:00 90.19
2009-01-12 16:00:00 88.28
2009-01-13 16:00:00 87.34
2009-01-14 16:00:00 84.97
2009-01-15 16:00:00 83.02
2009-01-16 16:00:00 81.98
2009-01-20 16:00:00 77.87
2009-01-21 16:00:00 82.48
2009-01-22 16:00:00 87.98
2009-01-23 16:00:00 87.98
...
2009-12-10 16:00:00 195.59
2009-12-11 16:00:00 193.84
2009-12-14 16:00:00 196.14
2009-12-15 16:00:00 193.34
2009-12-16 16:00:00 194.20
2009-12-17 16:00:00 191.04
2009-12-18 16:00:00 194.59
2009-12-21 16:00:00 197.38
2009-12-22 16:00:00 199.50
2009-12-23 16:00:00 201.24
2009-12-24 16:00:00 208.15
2009-12-28 16:00:00 210.71
2009-12-29 16:00:00 208.21
2009-12-30 16:00:00 210.74
2009-12-31 16:00:00 209.83
Name: AAPL, Length: 252
如您所见,简单地偏移 30 不会产生正确的结果,因为时间戳数据中存在间隙,并非每个月都是 30 天,等等。我知道必须有一种使用 pandas 的简单方法来做到这一点。