I have been trying to use the pyRserve for time series forecast and intent to use the auto.arima
function in R.
I used the following code to solve the problem of functions with a dot in their names such as 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)
but, it returned this error:
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
It seems the auto.arima
is not defined in Rserve. Why isn't it there? How can I fix this?