0
我有一個每日時間序列數據。我試圖通過乘以一些月度因素來糾正這些時間系列值。處理熊貓的時間序列數據
我的時間序列數據的樣子:
model:
2010-01-30 0.008909
2010-01-31 0.007562
2010-02-01 0.
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])
喜歡它做它喜歡手動校正
但我相信這不是正確的做法。有沒有簡單的方法來做到這一點:
@COLDSPEED,這就是我一直在尋找。謝謝:) – bikuser
@bikuser很高興能幫到你! –