pandas2ri.ri2py does not work as sample code in document

Issue #573 invalid
Stella Yang created an issue
  • version number for rpy2='3.0.5', R version 3.6.0, and Python 3.6.5 (pandas 0.23.1)
  • operating system used: MacOS Mojave 10.14.6

I am suffering from an error " AttributeError: module 'rpy2.robjects.pandas2ri' has no attribute 'ri2py'" when calling rpy2 from another package. I did dig into rpy2.robjects.pandas2ri by below test code which still lead me the same AttributeError.

from rpy2.robjects import r, pandas2ri


df = pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6], 'C':[7,8,9]}, index=["one", "two", "three"])


I have also tried the official doc, , where I got TypeError when loading iris data:

from rpy2.robjects import r, pandas2ri


Traceback (most recent call last):File "~/Library/Python/3.6/lib/python/site-packages/IPython/core/", line 2881, in run_codeexec(code_obj, self.user_global_ns, self.user_ns)File "<ipython-input-6-51634e710a66>", line 1, in <module>'iris')TypeError: 'DataFrame' object is not callable


BTW, my installation and R path does not seem have issue, after running check python -m rpy2.situation from related issues.

Python version:

3.6.5 (default, Apr 25 2018, 14:23:58)

[GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.1)]

Looking for R's HOME:

Environment variable R_HOME: None

Calling `R RHOME`: /Library/Frameworks/R.framework/Resources

InstallPath in the registry: *** Only available on Windows ***

R version:

In the PATH: R version 3.6.0 (2019-04-26) -- "Planting of a Tree"

Loading R library from rpy2: OK

Additional directories to load R packages from:


Comments (3)

  1. Laurent Gautier

    I am marking this as invalid because I suspect that this is due to trying to use code designed to work with an older version of rpy2 or follow outdated documentation. Reopen if I am wrong.

    The conversion system has changed a bit (see for current doc), and one way to work with pandas data frames is described in the documentation:

  2. Stella Yang reporter

    make sense to me. since rpy2 is a depend package used by another package, I will switch to 2.9.4 to try my luck

  3. Laurent Gautier

    Depending on the point of view, making the few adjustments needed by that package of yours to work with the latest rpy2 release might be a worthwhile small investment of time.

  4. Log in to comment