Rank23 / COVID19

Using Kalman Filter to Predict Corona Virus Spread
https://medium.com/@rank23/using-kalman-filter-to-predict-corona-virus-spread-72d91b74cc8
MIT License
80 stars 38 forks source link

Kalman filter prediction #9

Open metemu opened 4 years ago

metemu commented 4 years ago

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'
Rank23 commented 4 years ago

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