0
後不工作,我有一個大的數據幀temp_history:滾動標準偏差附加數據幀
Date Temp
2017-09-14 00:00:00 38.91588479
2017-09-13 00:00:00 38.69563395
2017-09-12 00:00:00 39.25504775
2017-09-11 00:00:00 40.5487144
2017-09-08 00:00:00 41.23372428
2017-09-07 00:00:00 41.5960891
2017-09-06 00:00:00 41.61939397
...
2016-11-30 00:00:00 37.32206175
2016-11-29 00:00:00 36.04661564
2016-11-28 00:00:00 35.70612757
2016-11-25 00:00:00 35.15249571
2016-11-23 00:00:00 36.77833439
...
而且我有今天的數據幀temp_today:
Date Temp
2017-09-15 08:59:02 62.85
現在我附上今日數據使用歷史記錄
temp_history = temp_history.append(temp_today)
這給合併數據框:
Date Temp
2017-09-15 08:59:02 62.85
2017-09-14 00:00:00 38.91588479
2017-09-13 00:00:00 38.69563395
2017-09-12 00:00:00 39.25504775
2017-09-11 00:00:00 40.5487144
2017-09-08 00:00:00 41.23372428
2017-09-07 00:00:00 41.5960891
2017-09-06 00:00:00 41.61939397
...
現在,當我試圖計算7天滾動STD它不工作:
temp_history['ST_std'] = temp_history['Temp'].resample('D').ffill().rolling('7D', min_periods=2).std() #rolling 3 mth std
它計算的一切,但忽略了今天的追加值在滾動std:
Date Temp ST_std
2017-09-15 13:59:02 62.85
2017-09-14 00:00:00 38.91588479 1.163391429
2017-09-13 00:00:00 38.69563395 1.126344307
2017-09-12 00:00:00 39.25504775 0.83068272
2017-09-11 00:00:00 40.5487144 0.831276056
2017-09-08 00:00:00 41.23372428 1.086552698
2017-09-07 00:00:00 41.5960891 0.93493231
2017-09-06 00:00:00 41.61939397 0.897336665
我該如何克等待滾動標準以包括今天的價值?
是對.resmaple這一點,因爲( 'd')只查找準確地24小時區別? – user44840