'pd.ewma'沒有這個模組,改用`Series.ewm` 或降低版本到 ... | Pd EWMA

pd.ewma(com=None, span=one) # 指數平均線。

com:資料;span:時間間隔AttributeError: module 'pandas' has no attribute 'ewma' ...pandas0.23.4:'pd.ewma'沒有這個模組,改用`Series.ewm`或降低版本到pandas0.21.0首頁HTMLCSSJavaScriptjQueryPython3Python2JavaCC++GoSQL首頁HTMLSearchpandas0.23.4:'pd.ewma'沒有這個模組,改用`Series.ewm`或降低版本到pandas0.21.02018-12-20254問題:在進行畫出指數平滑移動平均線,遇到如下問題:#pd.ewma(com=None,span=one)#指數平均線。

com:資料;span:時間間隔AttributeError:module'pandas'hasnoattribute'ewma'解決辦法:方法一:換用下面的方法#Series.ewm(com=None,span=None,halflife=None,alpha=None,min_periods=0,freq=None,adjust=True,ignore_na=False,axis=0)#com:float,optional#Specifydecayintermsofcenterofmass,\(\alpha=1/(1+com),\text{for}com\geq0\)#span:float,optional#Specifydecayintermsofspan,\(\alpha=2/(span+1),\text{for}span\geq1\)#halflife:float,optional#Specifydecayintermsofhalf-life,\(\alpha=1-exp(log(0.5)/halflife),\text{for}halflife>0\)#alpha:float,optional#Specifysmoothingfactor\(\alpha\)directly,\(0<\alpha\leq1\)#Newinversion0.18.0.#min_periods:int,default0#Minimumnumberofobservationsinwindowrequiredtohaveavalue(otherwiseresultisNA).#freq:Noneorstringalias/dateoffsetobject,default=None(DEPRECATED)#Frequencytoconformtobeforecomputingstatistic#adjust:boolean,defaultTrue#Dividebydecayingadjustmentfactorinbeginningperiodstoaccountforimbalanceinrelativeweightings(viewingEWMAasamovingaverage)#ignore_na:boolean,defaultFalse#Ignoremissingvalueswhencalculatingweights;specifyTruetoreproducepre-0.15.0behaviorstock_day["close"].ewm(span=30).mean().plot()方法二:在pandas0.23.4版本中,已經不存在這種方法,回退到之前版本pandas0.21.0就一切完美pipinstallpandas==0.21例項:#簡單移動平均線(SMA),又稱“算數移動平均線”,是指特定期間的收盤價進行平均化#例:5日的均線SMA=(C1+C2+C3+C4+C5)/5#Cn為資料中第n天的數#計算移動平均線,對每天的股票的收盤價進行計算close指標#pd.rolling_mean(data,window=5)#這種方法已經淘汰了data.rolling(window=n).mean().plot()#window=nn日的平均數#加權移動平均線(WMA):為了提高最近股票(收盤價)資料的影響,防止被平均#1)末日加權移動平均線:MA(N)=(C1+C2+C3+C4+...+Cn*2)/(n+1)#2)線性加權移動平均線(給的權重比例太大,導致最近的時間序列資料影響過大,一般不選擇):MA(N)=(C1+C2*2+C3*3+C4*4+...+Cn*n)/(1+2+...+n)#3)指數平滑移動平均線(EWMA):#提高最近的資料的比重,不存在給的過大;#比重都是小


常見投資理財問答


延伸文章資訊