源码

首页 » 归档 » 源码 » python – 模块’pandas’没有属性’rolling_me…

python – 模块’pandas’没有属性’rolling_me…


我正在尝试构建一个用于异常检测的ARIMA.我需要找到时间序列图的移动平均线我试图使用pandas 0.23

import pandas as pd
import numpy as np
from statsmodels.tsa.stattools import adfuller
import matplotlib.pylab as plt
from matplotlib.pylab import rcParams
rcParams['figure.figsize'] = 15, 6

dateparse = lambda dates: pd.datetime.strptime(dates, '%Y-%m')
data = pd.read_csv('AirPassengers.csv', parse_dates=['Month'], index_col='Month',date_parser=dateparse)

data.index
ts = data['#Passengers']
ts.head(10)

plt.plot(ts)
ts_log = np.log(ts)
plt.plot(ts_log)
moving_avg = pd.rolling_mean(ts_log,12)  # here is the error

pd.rolling_mean  
plt.plot(ts_log)
plt.plot(moving_avg, color='red') 

error:Traceback (most recent call last): File “C:/Program
Files/Python36/lastmainprogram.py”, line 74, in
moving_avg = pd.rolling_mean(ts_log,12) AttributeError: module ‘pandas’ has no attribute ‘rolling_mean’

(0)

本文由 投稿者 创作,文章地址:https://blog.isoyu.com/archives/python-mokuaipandasmeiyoushuxingrolling_me.html
采用知识共享署名4.0 国际许可协议进行许可。除注明转载/出处外,均为本站原创或翻译,转载前请务必署名。最后编辑时间为:9 月 27, 2019 at 09:50 上午

热评文章