我一直在尝试使用 pyRserve 进行时间序列预测,并打算auto.arima
在 R 中使用该函数。
我使用以下代码来解决名称中带有点的函数的问题,例如auto.arima
:
import pyRserve
import pandas as pd
import numpy
conn = pyRserve.connect()
df = pd.read_excel('D:/My Path/C9.xlsx', sheet_name='C9')
aList = df['Value'].tolist() # Cast the desired column into a python list
aList = numpy.array(aList)
conn.r.List = aList
auto_arima = getattr(conn.r, 'auto.arima')
conn.r.sapply(conn.ref.List, auto_arima)
但是,它返回了这个错误:
Traceback (most recent call last):
File "D:/Forecast/Python/R2Python/R2P_Practice.py", line 21, in <module>
auto_arima = getattr(conn.r, 'auto.arima')
File "C:\Python27\lib\site-packages\pyRserve\rconn.py", line 308, in __getattr__
'defined in Rserve' % realname)
NameError: no such variable or function "auto.arima" defined in Rserve
似乎auto.arima
Rserve 中没有定义。为什么不在那里?我怎样才能解决这个问题?