簡體   English   中英

重新采樣時間序列數據(Pandas Python 3)

[英]Resampling Time Series Data (Pandas Python 3)

嘗試將每日頻率轉換為每周頻率。

在:

weeklyaaapl = pd.DataFrame()
weeklyaapl['Open'] = aapl.Open.resample('W').iloc[0]

#here I am trying to take the first value of the aapl.Open,
#that falls within the week. 

出:

ValueError: .resample() is now a deferred operation
use .resample(...).mean() instead of .resample(...)

我想要真正的開放時間(本周打印的第一個開放時間)(該周第一天的開放時間)。 相反,它希望我使用.mean()來獲取給定一周的每日開放值的平均值,這不是我需要的信息。

似乎無法解釋該錯誤,文檔也無濟於事。

我認為你需要。

aapl.resample('W').first()

輸出:

             Open   High    Low  Close     Volume
Date                                             
2010-01-10  30.49  30.64  30.34  30.57  123432050
2010-01-17  30.40  30.43  29.78  30.02  115557365
2010-01-24  29.76  30.74  29.61  30.72  182501620
2010-01-31  28.93  29.24  28.60  29.01  266424802
2010-02-07  27.48  28.00  27.33  27.82  187468421

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM