Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ModuleNotFoundError: No module named 'pandas.rpy'

I'm trying to import pandas as pd. I get ModuleNotFoundError: No module named 'pandas.rpy'. Why? I use pandas 0.20.1 + python 3.6 x64 + Windows 7 .

Example:

import os
os.environ['R_HOME'] = 'C:\Program Files\R\R-3.4.0'
os.environ['R_USER'] = 'bob'

import rpy2.robjects as robjects
import pandas.rpy.common as com
import pandas as pd

Returns:

Traceback (most recent call last):
  File "C:\doc\GitHub\proj\src\open_rdata.py", line 19, in <module>
    import pandas.rpy.common as com
ModuleNotFoundError: No module named 'pandas.rpy'
like image 924
Franck Dernoncourt Avatar asked Jul 20 '17 17:07

Franck Dernoncourt


People also ask

Why is pandas not working?

The most frequent source of this error is that you haven't installed Pandas explicitly with pip install pandas . Alternatively, you may have different Python versions on your computer, and Pandas is not installed for the particular version you're using.


1 Answers

pandas.rpy module was deprecated and later removed. It does not exist in the version you are currently using.

You can either downgrade your pandas version, or better yet, have a look at the new rpy2 project.

From pandas documentation:

Up to pandas 0.19, a pandas.rpy module existed with functionality to convert between pandas and rpy2 objects. This functionality now lives in the rpy2 project itself. See the updating section of the previous documentation for a guide to port your code from the removed pandas.rpy to rpy2 functions.

You can see the rpy2 documentation here, and panda's reference for it here.

edit: per Analytical Monk's comment, corrected the phrasing to refer rpy2 as a different library, and not a part of pandas

like image 90
Ori Avatar answered Nov 15 '22 01:11

Ori