【发布时间】:2017-09-06 09:37:37
【问题描述】:
我有一个每日时间序列数据。我试图通过乘以一些月度因子来纠正这些时间序列值。它就像手动校正一样:
我的时间序列数据如下:
model:
2010-01-30 0.008909
2010-01-31 0.007562
2010-02-01 0.012377
2010-02-02 0.010286
2010-02-03 0.012244
2010-02-04 0.011367
2010-02-05 0.010800
2010-02-06 0.007610
2010-02-07 0.006534
2010-02-08 0.004721
...
2015-12-02 0.005415
2015-12-03 0.004358
2015-12-04 0.006844
2015-12-05 0.002373
我有一个每月的因素,例如:
mon_slope:
month
January -0.168627
February -0.165102
March -0.112321
April -0.112232
May -0.080092
June -0.129905
July -0.078751
August -0.095756
September -0.090188
October -0.109919
November -0.155380
December -0.137885
Name: slope, dtype: float64
我做了什么:
jan_corr = pd.DataFrame(model[model.index.month ==1]*mon_slope.ix[0][1])
feb_corr = pd.DataFrame(model[model.index.month ==2]*mon_slope.ix[1][1])
mar_corr = pd.DataFrame(model[model.index.month ==3]*mon_slope.ix[2][1])
..................
..................
final = pd.concat([jan_corr,feb_corr,mar_corr])
但我确信这不是正确的做法。有没有更简单的方法来做到这一点:
【问题讨论】:
标签: python pandas dataframe time-series