pandas中沒有了'rolling_mean' 'rolling_std' 'ewma'


rolmean = pd.rolling_mean(timeseries, window=12)

rolstd = pd.rolling_std(timeseries, window=12)

expwighted_avg = pd.ewma(ts_log, halflife=12)

會有報錯

AttributeError: module 'pandas' has no attribute 'rolling_mean'

AttributeError: module 'pandas' has no attribute 'rolling_std'

AttributeError: module 'pandas' has no attribute 'ewma'

這是因為pandas版本跟新了,應該改為

rolmean = timeseries.rolling(12).mean()
rolstd = timeseries.rolling(12).std()

expwighted_avg = pd.DataFrame.ewm(ts_log, halflife=12).mean()


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM