COVID19 icon indicating copy to clipboard operation
COVID19 copied to clipboard

Kalman filter prediction

Open metemu opened this issue 4 years ago • 1 comments

I'm having trouble with r code snippet of kalman filter:

p=%R pred_all

gives an error like below. Can you please help me to solve this error?

AttributeError: type object 'DataFrame' has no attribute 'from_items'

Detailed error message:

AttributeError Traceback (most recent call last) in ----> 1 p=get_ipython().run_line_magic('R', 'pred_all')

~\anaconda\lib\site-packages\IPython\core\interactiveshell.py in run_line_magic(self, magic_name, line, _stack_depth) 2315 kwargs['local_ns'] = sys._getframe(stack_depth).f_locals 2316 with self.builtin_trap: -> 2317 result = fn(*args, **kwargs) 2318 return result 2319

in R(self, line, cell, local_ns)

~\anaconda\lib\site-packages\IPython\core\magic.py in (f, *a, **k) 185 # but it's overkill for just that one bit of state. 186 def magic_deco(arg): --> 187 call = lambda f, *a, **k: f(*a, **k) 188 189 if callable(arg):

~\anaconda\lib\site-packages\rpy2\ipython\rmagic.py in R(self, line, cell, local_ns) 755 if result is not ri.NULL: 756 with localconverter(converter) as cv: --> 757 res = cv.ri2py(result) 758 return res 759

~\anaconda\lib\functools.py in wrapper(*args, **kw) 838 '1 positional argument') 839 --> 840 return dispatch(args[0].class)(*args, **kw) 841 842 funcname = getattr(func, 'name', 'singledispatch function')

~\anaconda\lib\site-packages\rpy2\robjects\pandas2ri.py in ri2py_dataframe(obj) 189 def ri2py_dataframe(obj): 190 items = tuple((k, ri2py(v)) for k, v in obj.items()) --> 191 res = PandasDataFrame.from_items(items) 192 return res 193

AttributeError: type object 'DataFrame' has no attribute 'from_items'

metemu avatar May 09 '20 13:05 metemu

Can you verify 'rpy2' is well installed and you are allowed to pass df objects from R to Python? Try a simple example.

Rank23 avatar May 10 '20 19:05 Rank23