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'
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With