rpy2 import is not working

后端 未结 8 1129
逝去的感伤
逝去的感伤 2021-02-14 16:16

I get an error when I try to import rpy2. Here is the code and error.

>>> import pandas.rpy.common
Traceback (most recent call last):  

File \"C:\\PF\         


        
相关标签:
8条回答
  • 2021-02-14 16:37

    In my case it worked when I installed it in Anaconda Prompt with a command:

    conda install -m rpy2

    After that I had to move rpy2 directory from rpy2-2.9.0-py3.6-win32.egg (folder that was installed to) cause it didn't recognized it after installation...and moved only rpy2 folder to the following path:

    C:\Users..\Anaconda3\Lib\site-packages (where all packages are called from)

    That solved problem for me.

    0 讨论(0)
  • 2021-02-14 16:42

    This might not apply directly to your question, but ever since pandas and rpy2 have upgraded, their interface has changed. In order to set it up, you must now:

    from rpy2.robjects import r, pandas2ri
    
    pandas2ri.activate()
    

    Now, in order to change a Pandas dataframe into an R dataframe, one must use pandas2ri.py2ri(), or use pandas2ri.ri2py() if you want change an R dataframe into a Pandas dataframe. Further information can be found at https://pandas.pydata.org/pandas-docs/stable/r_interface.html.

    0 讨论(0)
提交回复
热议问题